diff --git a/MtApi5/Mt5Enums.cs b/MtApi5/Mt5Enums.cs index edb532b9..b90ae547 100755 --- a/MtApi5/Mt5Enums.cs +++ b/MtApi5/Mt5Enums.cs @@ -112,11 +112,17 @@ namespace MtApi5 public enum ENUM_CHART_PROPERTY_STRING { - CHART_COMMENT = 20, - CHART_EXPERT_NAME = 113, - CHART_SCRIPT_NAME = 114 + CHART_COMMENT = 20, + CHART_EXPERT_NAME = 113, + CHART_SCRIPT_NAME = 114 } + public enum ENUM_CHART_POSITION + { + CHART_BEGIN = 0, // Chart beginning (the oldest prices) + CHART_CURRENT_POS = 1, // Current position + CHART_END = 2 // Chart end (the latest prices) + } #endregion diff --git a/MtApi5/MtApi5Client.cs b/MtApi5/MtApi5Client.cs index 2ce0d9a2..9a2bbfc2 100755 --- a/MtApi5/MtApi5Client.cs +++ b/MtApi5/MtApi5Client.cs @@ -1791,9 +1791,9 @@ namespace MtApi5 /// ///Returns true if successful, otherwise returns false. /// - public bool ChartNavigate(long chartId, int position, int shift = 0) + public bool ChartNavigate(long chartId, ENUM_CHART_POSITION position, int shift = 0) { - var commandParameters = new ArrayList { chartId, position, shift }; + var commandParameters = new ArrayList { chartId, (int)position, shift }; return SendCommand(Mt5CommandType.ChartNavigate, commandParameters); } diff --git a/mq5/MtApi5.ex5 b/mq5/MtApi5.ex5 index b0beed94..1e660d9c 100755 Binary files a/mq5/MtApi5.ex5 and b/mq5/MtApi5.ex5 differ diff --git a/mq5/MtApi5.mq5 b/mq5/MtApi5.mq5 index 2096c1eb..b5b59603 100644 --- a/mq5/MtApi5.mq5 +++ b/mq5/MtApi5.mq5 @@ -774,6 +774,9 @@ int executeCommand() case 252: //ChartGetString Execute_ChartGetString(); break; + case 253: //ChartNavigate + Execute_ChartNavigate(); + break; default: Print("Unknown command type = ", commandType); sendVoidResponse(ExpertHandle, _response_error); @@ -812,6 +815,7 @@ int executeCommand() #define SEND_ULONG_RESPONSE(response) SEND_RESPONSE_OR_PRINT_ERROR(sendULongResponse, response, __FUNCTION__) #define SEND_BOOL_RESPONSE(response) SEND_RESPONSE_OR_PRINT_ERROR(sendBooleanResponse, response, __FUNCTION__) #define SEND_DOUBLE_RESPONSE(response) SEND_RESPONSE_OR_PRINT_ERROR(sendDoubleResponse, response, __FUNCTION__) +#define SEND_STRING_RESPONSE(response) SEND_RESPONSE_OR_PRINT_ERROR(sendStringResponse, response, __FUNCTION__) //------------------------------------------------------------- @@ -5824,7 +5828,7 @@ void Execute_ChartGetDouble() void Execute_ChartGetInteger() { - long chart_id; + long chart_id; int prop_id; int sub_window; @@ -5845,6 +5849,52 @@ void Execute_ChartGetInteger() SEND_LONG_RESPONSE(result) } +void Execute_ChartGetString() +{ + long chart_id; + int prop_id; + + GET_LONG_VALUE(0, chart_id, "chart_id") + GET_INT_VALUE(1, prop_id, "prop_id") + +#ifdef __DEBUG_LOG__ + PrintFormat("%s: chart_id = %d, prop_id = %d", __FUNCTION__, chart_id, prop_id); +#endif + + string result = ChartGetString(chart_id, (ENUM_CHART_PROPERTY_STRING)prop_id); + +#ifdef __DEBUG_LOG__ + PrintFormat("%s: result = %s", __FUNCTION__, result); +#endif + + SEND_STRING_RESPONSE(result) + + ChartRedraw(chart_id); +} + +void Execute_ChartNavigate() +{ + long chart_id; + int position; + int shift; + + GET_LONG_VALUE(0, chart_id, "chart_id") + GET_INT_VALUE(1, position, "position") + GET_INT_VALUE(2, shift, "shift") + +#ifdef __DEBUG_LOG__ + PrintFormat("%s: chart_id = %d, position = %d, shift = %d", __FUNCTION__, chart_id, position, shift); +#endif + + bool result = ChartNavigate(chart_id, (ENUM_CHART_POSITION)position, shift); + +#ifdef __DEBUG_LOG__ + PrintFormat("%s: result = %s", __FUNCTION__, BoolToString(result)); +#endif + + SEND_BOOL_RESPONSE(result) +} + void Execute_ChartApplyTemplate() { long ChartId; @@ -5923,31 +5973,6 @@ void Execute_ChartWindowFind() SEND_INT_RESPONSE(result) } -void Execute_ChartGetString() -{ - long ChartId; - int PropId; - - if (!getLongValue(ExpertHandle, 0, ChartId, _error)) - { - PrintParamError("ChartGetString", "ChartId", _error); - sendErrorResponse(ExpertHandle, -1, _error, _response_error); - return; - } - if (!getIntValue(ExpertHandle, 1, PropId, _error)) - { - PrintParamError("ChartGetString", "PropId", _error); - sendErrorResponse(ExpertHandle, -1, _error, _response_error); - return; - } - - if (!sendStringResponse(ExpertHandle, ChartGetString(ChartId, (ENUM_CHART_PROPERTY_STRING)PropId), _response_error)) - { - PrintResponseError("ChartGetString", _response_error); - } - ChartRedraw(ChartId); -} - void Execute_TerminalInfoString() { int propertyId;