diff --git a/MtApi5/Mt5CommandType.cs b/MtApi5/Mt5CommandType.cs index 9d1282c1..7232feb0 100755 --- a/MtApi5/Mt5CommandType.cs +++ b/MtApi5/Mt5CommandType.cs @@ -179,8 +179,6 @@ namespace MtApi5 IndicatorRelease = 131, - - //Chart Operations ChartId = 206, ChartRedraw = 207, @@ -212,7 +210,9 @@ namespace MtApi5 ChartYOnDropped = 261, ChartSetSymbolPeriod = 262, ChartScreenShot = 263, - + ChartIndicatorAdd = 280, + ChartIndicatorGet = 281, + // Windows Operations WindowBarsPerChart = 264, WindowExpertName = 265, diff --git a/MtApi5/MtApi5Client.cs b/MtApi5/MtApi5Client.cs index 38ee4f88..36c1cf66 100755 --- a/MtApi5/MtApi5Client.cs +++ b/MtApi5/MtApi5Client.cs @@ -1797,6 +1797,21 @@ namespace MtApi5 return SendCommand(Mt5CommandType.ChartNavigate, commandParameters); } + /// + ///Adds an indicator with the specified handle into a specified chart window. Indicator and chart should be generated on the same symbol and time frame. + /// + ///Chart ID. 0 means the current chart. + ///Number of the chart subwindow. 0 denotes the main chart subwindow. + ///The handle of the indicator. + /// + ///The function returns true in case of success, otherwise it returns false. + /// + public bool ChartIndicatorAdd(long chartId, int subWindow, int indicatorHandle) + { + var commandParameters = new ArrayList { chartId, subWindow, indicatorHandle }; + return SendCommand(Mt5CommandType.ChartIndicatorAdd, commandParameters); + } + /// ///Removes an indicator with a specified name from the specified chart window. /// @@ -1812,6 +1827,21 @@ namespace MtApi5 return SendCommand(Mt5CommandType.ChartIndicatorDelete, commandParameters); } + /// + ///Returns the handle of the indicator with the specified short name in the specified chart window. + /// + ///Chart ID. 0 means the current chart. + ///Number of the chart subwindow. 0 denotes the main chart subwindow. + ///The short name of the indicator which is set in the INDICATOR_SHORTNAME property with the IndicatorSetString() function. To get the short name of an indicator use the ChartIndicatorName() function. + /// + ///Returns an indicator handle if successful, otherwise returns INVALID_HANDLE. + /// + public int ChartIndicatorGet(long chartId, int subWindow, string indicatorShortname) + { + var commandParameters = new ArrayList { chartId, subWindow, indicatorShortname }; + return SendCommand(Mt5CommandType.ChartIndicatorGet, commandParameters); + } + /// ///Returns the short name of the indicator by the number in the indicators list on the specified chart window. /// diff --git a/mq5/MtApi5.ex5 b/mq5/MtApi5.ex5 index 182b00d4..cc739242 100755 Binary files a/mq5/MtApi5.ex5 and b/mq5/MtApi5.ex5 differ diff --git a/mq5/MtApi5.mq5 b/mq5/MtApi5.mq5 index d41b74ba..3725a5e5 100644 --- a/mq5/MtApi5.mq5 +++ b/mq5/MtApi5.mq5 @@ -807,6 +807,12 @@ int executeCommand() case 263: //ChartScreenShot Execute_ChartScreenShot(); break; + case 280: //ChartIndicatorAdd + Execute_ChartIndicatorAdd(); + break; + case 281: //ChartIndicatorGet + Execute_ChartIndicatorGet(); + break; default: Print("Unknown command type = ", commandType); sendVoidResponse(ExpertHandle, _response_error); @@ -6100,6 +6106,53 @@ void Execute_ChartScreenShot() SEND_BOOL_RESPONSE(result) } +void Execute_ChartIndicatorAdd() +{ + long chart_id; + int sub_window; + int indicator_handle; + + GET_LONG_VALUE(0, chart_id, "chart_id") + GET_INT_VALUE(2, sub_window, "sub_window") + GET_INT_VALUE(3, indicator_handle, "indicator_handle") + +#ifdef __DEBUG_LOG__ + PrintFormat("%s: chart_id = %I64d, sub_window = %d, indicator_handle = %d", __FUNCTION__, chart_id, sub_window, indicator_handle); +#endif + + bool result = ChartIndicatorAdd(chart_id, sub_window, indicator_handle); + +#ifdef __DEBUG_LOG__ + PrintFormat("%s: result = %s", __FUNCTION__, BoolToString(result)); +#endif + + SEND_BOOL_RESPONSE(result) +} + +void Execute_ChartIndicatorGet() +{ + long chart_id; + int sub_window; + string indicator_shortname; + StringInit(indicator_shortname, 1000); + + GET_LONG_VALUE(0, chart_id, "chart_id") + GET_INT_VALUE(1, sub_window, "sub_window") + GET_STRING_VALUE(2, indicator_shortname, "indicator_shortname") + +#ifdef __DEBUG_LOG__ + PrintFormat("%s: chart_id = %I64d, sub_window = %d, indicator_shortname = %s", __FUNCTION__, chart_id, sub_window, indicator_shortname); +#endif + + int result = ChartIndicatorGet( chart_id, sub_window, indicator_shortname); + +#ifdef __DEBUG_LOG__ + PrintFormat("%s: result = %d", __FUNCTION__, result); +#endif + + SEND_INT_RESPONSE(result) +} + void Execute_ChartApplyTemplate() { long ChartId;