diff --git a/Draw.mqh b/Draw.mqh index 0e637d088..c6c200af3 100644 --- a/Draw.mqh +++ b/Draw.mqh @@ -32,9 +32,11 @@ class Draw; // Includes. #include "Data.define.h" #include "Object.extern.h" -//#include "Platform.h" #include "Object.mqh" +#include "Platform.extern.h" #include "Terminal.define.h" +#include "Terminal.enum.h" +#include "Terminal.extern.h" #ifndef __MQL4__ // Defines macros (for MQL4 backward compatibility). @@ -46,7 +48,7 @@ class Draw; #define WINDOW_MAIN 0 -#ifdef __MQL5__ +#ifndef __MQL4__ #define OBJPROP_TIME1 ((ENUM_OBJECT_PROPERTY_INTEGER)0) #define OBJPROP_PRICE1 1 #define OBJPROP_TIME2 2 @@ -157,24 +159,6 @@ class Draw : public Object { return ::ObjectSet(name, prop_id, prop_value); #else // __MQL5__ switch (prop_id) { - // Datetime value to set/get first coordinate time part. - case OBJPROP_TIME1: - return ObjectSetInteger(chart_id, name, OBJPROP_TIME, (long)prop_value); - // Datetime value to set/get second coordinate time part. - case OBJPROP_TIME2: - return ObjectSetInteger(chart_id, name, OBJPROP_TIME, 1, (long)prop_value); - // Datetime value to set/get third coordinate time part. - case OBJPROP_TIME3: - return ObjectSetInteger(chart_id, name, OBJPROP_TIME, 2, (long)prop_value); - // Double value to set/get first coordinate price part. - case OBJPROP_PRICE1: - return ObjectSetDouble(chart_id, name, OBJPROP_PRICE, (double)prop_value); - // Double value to set/get second coordinate price part. - case OBJPROP_PRICE2: - return ObjectSetDouble(chart_id, name, OBJPROP_PRICE, 1, prop_value); - // Double value to set/get third coordinate price part. - case OBJPROP_PRICE3: - return ObjectSetDouble(chart_id, name, OBJPROP_PRICE, 2, prop_value); case OBJPROP_ANGLE: // Double value to set/get angle object property in degrees. case OBJPROP_DEVIATION: // Double value to set/get deviation property for Standard deviation objects. case OBJPROP_SCALE: // Double value to set/get scale object property. @@ -203,6 +187,29 @@ class Draw : public Object { default: break; } + + // MQL4 enum values. + switch (prop_id) { + // Datetime value to set/get first coordinate time part. + case OBJPROP_TIME1: + return ObjectSetInteger(chart_id, name, OBJPROP_TIME, (long)prop_value); + // Datetime value to set/get second coordinate time part. + case OBJPROP_TIME2: + return ObjectSetInteger(chart_id, name, OBJPROP_TIME, 1, (long)prop_value); + // Datetime value to set/get third coordinate time part. + case OBJPROP_TIME3: + return ObjectSetInteger(chart_id, name, OBJPROP_TIME, 2, (long)prop_value); + // Double value to set/get first coordinate price part. + case OBJPROP_PRICE1: + return ObjectSetDouble(chart_id, name, OBJPROP_PRICE, (double)prop_value); + // Double value to set/get second coordinate price part. + case OBJPROP_PRICE2: + return ObjectSetDouble(chart_id, name, OBJPROP_PRICE, 1, prop_value); + // Double value to set/get third coordinate price part. + case OBJPROP_PRICE3: + return ObjectSetDouble(chart_id, name, OBJPROP_PRICE, 2, prop_value); + } + return (false); #endif } @@ -261,7 +268,7 @@ class Draw : public Object { * Draw a vertical line. */ bool DrawVLine(string oname, datetime tm) { - bool result = Draw::ObjectCreate(NULL, oname, OBJ_VLINE, 0, tm, 0); + bool result = Draw::ObjectCreate(NULL_VALUE, oname, OBJ_VLINE, 0, tm, 0); if (!result) PrintFormat("%(): Can't create vertical line! code #", __FUNCTION__, GetLastError()); return (result); } @@ -270,7 +277,7 @@ class Draw : public Object { * Draw a horizontal line. */ bool DrawHLine(string oname, double value) { - bool result = Draw::ObjectCreate(NULL, oname, OBJ_HLINE, 0, 0, value); + bool result = Draw::ObjectCreate(NULL_VALUE, oname, OBJ_HLINE, 0, 0, value); if (!result) PrintFormat("%(): Can't create horizontal line! code #", __FUNCTION__, GetLastError()); return (result); } @@ -279,7 +286,7 @@ class Draw : public Object { * Delete a vertical line. */ bool DeleteVertLine(string oname) { - bool result = Draw::ObjectDelete(NULL, oname); + bool result = Draw::ObjectDelete(NULL_VALUE, oname); if (!result) PrintFormat("%(): Can't delete vertical line! code #", __FUNCTION__, GetLastError()); return (result); } diff --git a/DrawIndicator.mqh b/DrawIndicator.mqh index d1ec770be..02fbc3ec0 100644 --- a/DrawIndicator.mqh +++ b/DrawIndicator.mqh @@ -48,7 +48,7 @@ class DrawPoint { } // Special methods. DrawPoint(const DrawPoint& r) : time(r.time), value(r.value) {} - DrawPoint(datetime _time = NULL, double _value = 0) : time(_time), value(_value) {} + DrawPoint(datetime _time = 0, double _value = 0) : time(_time), value(_value) {} }; class DrawIndicator { @@ -124,7 +124,8 @@ class DrawIndicator { } if (!last_points.KeyExists(_name)) { - last_points.Set(_name, DrawPoint(_time, _value)); + DrawPoint _point(_time, _value); + last_points.Set(_name, _point); } else { DrawPoint* last_point = last_points.GetByKey(_name); diff --git a/Platform.extern.h b/Platform.extern.h index 943ec3bcd..8f6e8e7cf 100644 --- a/Platform.extern.h +++ b/Platform.extern.h @@ -27,6 +27,7 @@ // Includes. #include "Deal.enum.h" #include "Order.define.h" +#include "Terminal.enum.h" // Forward declarations. struct MqlTradeRequest; @@ -137,4 +138,32 @@ extern string AccountInfoInteger(ENUM_ACCOUNT_INFO_STRING property_id); extern string Symbol(); +extern string ObjectName(long _chart_id, int _pos, int _sub_window = -1, int _type = -1); + +extern int ObjectsTotal(long chart_id, int type = EMPTY, int window = -1); + +extern bool PlotIndexSetString(int plot_index, int prop_id, string prop_value); + +extern bool PlotIndexSetInteger(int plot_index, int prop_id, int prop_value); + +extern bool ObjectSetInteger(long chart_id, string name, ENUM_OBJECT_PROPERTY_INTEGER prop_id, long prop_value); + +extern bool ObjectSetInteger(long chart_id, string name, ENUM_OBJECT_PROPERTY_INTEGER prop_id, int prop_modifier, + long prop_value); + +extern bool ObjectSetDouble(long chart_id, string name, ENUM_OBJECT_PROPERTY_DOUBLE prop_id, double prop_value); + +extern bool ObjectSetDouble(long chart_id, string name, ENUM_OBJECT_PROPERTY_DOUBLE prop_id, int prop_modifier, + double prop_value); + +extern bool ObjectCreate(long _cid, string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1); +extern bool ObjectCreate(long _cid, string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1, + datetime _t2, double _p2); + +extern bool ObjectMove(long chart_id, string name, int point_index, datetime time, double price); + +extern bool ObjectDelete(long chart_id, string name); + +extern int ObjectFind(long chart_id, string name); + #endif diff --git a/Platform.h b/Platform.h index 90f8440cf..a2408db20 100644 --- a/Platform.h +++ b/Platform.h @@ -581,6 +581,76 @@ string Symbol() { return false; } +string ObjectName(long _chart_id, int _pos, int _sub_window = -1, int _type = -1) { + Print("Not yet implemented: ", __FUNCTION__, " returns empty string."); + return ""; +} + +int ObjectsTotal(long chart_id, int type = EMPTY, int window = -1) { + Print("Not yet implemented: ", __FUNCTION__, " returns 0."); + return 0; +} + +bool PlotIndexSetString(int plot_index, int prop_id, string prop_value) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +bool PlotIndexSetInteger(int plot_index, int prop_id, int prop_value) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +bool ObjectSetInteger(long chart_id, string name, ENUM_OBJECT_PROPERTY_INTEGER prop_id, long prop_value) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +bool ObjectSetInteger(long chart_id, string name, ENUM_OBJECT_PROPERTY_INTEGER prop_id, int prop_modifier, + long prop_value) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +bool ObjectSetDouble(long chart_id, string name, ENUM_OBJECT_PROPERTY_DOUBLE prop_id, double prop_value) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +bool ObjectSetDouble(long chart_id, string name, ENUM_OBJECT_PROPERTY_DOUBLE prop_id, int prop_modifier, + double prop_value) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +bool ObjectCreate(long _cid, string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +bool ObjectCreate(long _cid, string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1, datetime _t2, + double _p2) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +bool ObjectMove(long chart_id, string name, int point_index, datetime time, double price) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +bool ObjectDelete(long chart_id, string name) { + Print("Not yet implemented: ", __FUNCTION__, " returns false."); + return false; +} + +int GetLastError() { return _LastError; } + +int ObjectFind(long chart_id, string name) { + Print("Not yet implemented: ", __FUNCTION__, " returns 0."); + return 0; +} + #endif /** diff --git a/Storage/ValueStorage.indicator.h b/Storage/ValueStorage.indicator.h index 06c125d80..54c249bf6 100644 --- a/Storage/ValueStorage.indicator.h +++ b/Storage/ValueStorage.indicator.h @@ -36,7 +36,6 @@ template class HistoryValueStorage; // Includes. -#include "../Indicator/IndicatorData.h" #include "ValueStorage.history.h" /** diff --git a/Terminal.enum.h b/Terminal.enum.h index 386caf381..5e56a0fe6 100644 --- a/Terminal.enum.h +++ b/Terminal.enum.h @@ -230,4 +230,109 @@ enum ENUM_UNINIT_REASON { REASON_INITFAILED = 8, REASON_CLOSE = 9, }; + +enum ENUM_DRAW_TYPE { + DRAW_NONE, + DRAW_LINE, + DRAW_SECTION, + DRAW_HISTOGRAM, + DRAW_HISTOGRAM2, + DRAW_ARROW, + DRAW_ZIGZAG, + DRAW_FILLING, + DRAW_BARS, + DRAW_CANDLES, + DRAW_COLOR_LINE, + DRAW_COLOR_SECTION, + DRAW_COLOR_HISTOGRAM, + DRAW_COLOR_HISTOGRAM2, + DRAW_COLOR_ARROW, + DRAW_COLOR_ZIGZAG, + DRAW_COLOR_BARS, + DRAW_COLOR_CANDLES +}; + +enum ENUM_PLOT_PROPERTY_INTEGER { + PLOT_ARROW, + PLOT_ARROW_SHIFT, + PLOT_DRAW_BEGIN, + PLOT_DRAW_TYPE, + PLOT_SHOW_DATA, + PLOT_SHIFT, + PLOT_LINE_STYLE, + PLOT_LINE_WIDTH, + PLOT_COLOR_INDEXES, + PLOT_LINE_COLOR +}; + +enum ENUM_PLOT_PROPERTY_DOUBLE { PLOT_EMPTY_VALUE }; + +enum ENUM_PLOT_PROPERTY_STRING { PLOT_LABEL }; + +enum ENUM_LINE_STYLE { STYLE_SOLID, STYLE_DASH, STYLE_DOT, STYLE_DASHDOT, STYLE_DASHDOTDOT }; + +enum ENUM_OBJECT_PROPERTY_INTEGER { + OBJPROP_COLOR, + OBJPROP_STYLE, + OBJPROP_WIDTH, + OBJPROP_BACK, + OBJPROP_ZORDER, + OBJPROP_FILL, + OBJPROP_HIDDEN, + OBJPROP_SELECTED, + OBJPROP_READONLY, + OBJPROP_TYPE, + OBJPROP_TIME, + OBJPROP_SELECTABLE, + OBJPROP_CREATETIME, + OBJPROP_LEVELS, + OBJPROP_LEVELCOLOR, + OBJPROP_LEVELSTYLE, + OBJPROP_LEVELWIDTH, + OBJPROP_ALIGN, + OBJPROP_FONTSIZE, + OBJPROP_RAY_LEFT, + OBJPROP_RAY_RIGHT, + OBJPROP_RAY, + OBJPROP_ELLIPSE, + OBJPROP_ARROWCODE, + OBJPROP_TIMEFRAMES, + OBJPROP_ANCHOR, + OBJPROP_XDISTANCE, + OBJPROP_YDISTANCE, + OBJPROP_DIRECTION, + OBJPROP_DEGREE, + OBJPROP_DRAWLINES, + OBJPROP_STATE, + OBJPROP_CHART_ID, + OBJPROP_XSIZE, + OBJPROP_YSIZE, + OBJPROP_XOFFSET, + OBJPROP_YOFFSET, + OBJPROP_PERIOD, + OBJPROP_DATE_SCALE, + OBJPROP_PRICE_SCALE, + OBJPROP_CHART_SCALE, + OBJPROP_BGCOLOR, + OBJPROP_CORNER, + OBJPROP_BORDER_TYPE, + OBJPROP_BORDER_COLOR +}; + +enum ENUM_OBJECT_PROPERTY_DOUBLE { OBJPROP_PRICE, OBJPROP_LEVELVALUE, OBJPROP_SCALE, OBJPROP_ANGLE, OBJPROP_DEVIATION }; + +enum ENUM_OBJECT_PROPERTY_STRING { + OBJPROP_NAME, + OBJPROP_TEXT, + OBJPROP_TOOLTIP, + OBJPROP_LEVELTEXT, + OBJPROP_FONT, + OBJPROP_BMPFILE, + OBJPROP_SYMBOL +}; + +enum ENUM_BORDER_TYPE { BORDER_FLAT, BORDER_RAISED, BORDER_SUNKEN }; + +enum ENUM_ALIGN_MODE { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT }; + #endif