Implemented functions ChartId, ChartRedraw, ChartWindowFind, ChartClose (MT5)

This commit is contained in:
vdemydiuk
2018-03-14 18:10:44 +02:00
parent 9afd30e463
commit 07dd83f890
3 changed files with 104 additions and 25 deletions
+2 -1
View File
@@ -1516,6 +1516,7 @@ namespace MtApi5
///<summary> ///<summary>
///This function calls a forced redrawing of a specified chart. ///This function calls a forced redrawing of a specified chart.
///</summary> ///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
public void ChartRedraw(long chartId = 0) public void ChartRedraw(long chartId = 0)
{ {
var commandParameters = new ArrayList { chartId }; var commandParameters = new ArrayList { chartId };
@@ -1660,7 +1661,7 @@ namespace MtApi5
///<returns> ///<returns>
///If successful, returns true, otherwise false. ///If successful, returns true, otherwise false.
///</returns> ///</returns>
public bool ChartClose(long chartId) public bool ChartClose(long chartId = 0)
{ {
var commandParameters = new ArrayList { chartId }; var commandParameters = new ArrayList { chartId };
return SendCommand<bool>(Mt5CommandType.ChartClose, commandParameters); return SendCommand<bool>(Mt5CommandType.ChartClose, commandParameters);
BIN
View File
Binary file not shown.
+102 -24
View File
@@ -723,12 +723,21 @@ int executeCommand()
case 205: //TerminalInfoDouble case 205: //TerminalInfoDouble
Execute_TerminalInfoDouble(); Execute_TerminalInfoDouble();
break; break;
case 206: //ChartId
Execute_ChartId();
break;
case 207: //ChartRedraw
Execute_ChartRedraw();
break;
case 236: //ChartApplyTemplate case 236: //ChartApplyTemplate
Execute_ChartApplyTemplate(); Execute_ChartApplyTemplate();
break; break;
case 237: //ChartApplyTemplate case 237: //ChartApplyTemplate
Execute_ChartSaveTemplate(); Execute_ChartSaveTemplate();
break; break;
case 238: //ChartWindowFind
Execute_ChartWindowFind();
break;
case 241: //ChartOpen case 241: //ChartOpen
Execute_ChartOpen(); Execute_ChartOpen();
break; break;
@@ -738,6 +747,9 @@ int executeCommand()
case 243: //ChartFirst case 243: //ChartFirst
Execute_ChartNext(); Execute_ChartNext();
break; break;
case 244: //ChartClose
Execute_ChartClose();
break;
case 245: //ChartFirst case 245: //ChartFirst
Execute_ChartSymbol(); Execute_ChartSymbol();
break; break;
@@ -755,15 +767,16 @@ int executeCommand()
//------ helper macros to get and send values ------------------ //------ helper macros to get and send values ------------------
#define GET_VALUE_OR_RETURN_WITH_SENDING_ERROR(get_func, argument_id, argument, cmd_name, param_name) if (!get_func(ExpertHandle, argument_id, argument, _error)) \ #define GET_VALUE_OR_RETURN_WITH_SENDING_ERROR(get_func, argument_id, argument, func_name, argument_name) if (!get_func(ExpertHandle, argument_id, argument, _error)) \
{ \ { \
PrintParamError(cmd_name, param_name, _error); \ PrintParamError(func_name, argument_name, _error); \
sendErrorResponse(ExpertHandle, -1, _error, _response_error); \ sendErrorResponse(ExpertHandle, -1, _error, _response_error); \
return; \ return; \
} \ } \
#define GET_INT_VALUE(argument_id, argument, cmd_name, param_name) GET_VALUE_OR_RETURN_WITH_SENDING_ERROR(getIntValue, argument_id, argument, cmd_name, param_name) #define GET_INT_VALUE(argument_id, argument, argument_name) GET_VALUE_OR_RETURN_WITH_SENDING_ERROR(getIntValue, argument_id, argument, __FUNCTION__, argument_name)
#define GET_STRING_VALUE(argument_id, argument, cmd_name, param_name) GET_VALUE_OR_RETURN_WITH_SENDING_ERROR(getStringValue, argument_id, argument, cmd_name, param_name) #define GET_LONG_VALUE(argument_id, argument, argument_name) GET_VALUE_OR_RETURN_WITH_SENDING_ERROR(getLongValue, argument_id, argument, __FUNCTION__, argument_name)
#define GET_STRING_VALUE(argument_id, argument, argument_name) GET_VALUE_OR_RETURN_WITH_SENDING_ERROR(getStringValue, argument_id, argument, __FUNCTION__, argument_name)
#define SEND_RESPONSE_OR_PRINT_ERROR(send_func, response, cmd_name) if (!send_func(ExpertHandle, response, _response_error)) \ #define SEND_RESPONSE_OR_PRINT_ERROR(send_func, response, cmd_name) if (!send_func(ExpertHandle, response, _response_error)) \
@@ -771,9 +784,15 @@ int executeCommand()
PrintResponseError(cmd_name, _response_error); \ PrintResponseError(cmd_name, _response_error); \
} }
#define SEND_INT_RESPONSE(response, cmd_name) SEND_RESPONSE_OR_PRINT_ERROR(sendIntResponse, response, cmd_name) #define SEND_VOID_RESPONSE if (!sendVoidResponse(ExpertHandle, _response_error)) \
#define SEND_LONG_RESPONSE(response, cmd_name) SEND_RESPONSE_OR_PRINT_ERROR(sendLongResponse, response, cmd_name) { \
#define SEND_ULONG_RESPONSE(response, cmd_name) SEND_RESPONSE_OR_PRINT_ERROR(sendULongResponse, response, cmd_name) PrintResponseError(__FUNCTION__, _response_error); \
}
#define SEND_INT_RESPONSE(response) SEND_RESPONSE_OR_PRINT_ERROR(sendIntResponse, response, __FUNCTION__)
#define SEND_LONG_RESPONSE(response) SEND_RESPONSE_OR_PRINT_ERROR(sendLongResponse, response, __FUNCTION__)
#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__)
//------------------------------------------------------------- //-------------------------------------------------------------
@@ -946,7 +965,7 @@ void Execute_OrderCalcProfit()
void Execute_PositionGetTicket() void Execute_PositionGetTicket()
{ {
int index; int index;
GET_INT_VALUE(0, index, "PositionGetTicket", "index"); GET_INT_VALUE(0, index, "index");
#ifdef __DEBUG_LOG__ #ifdef __DEBUG_LOG__
PrintFormat("%s: index = %d", __FUNCTION__, index); PrintFormat("%s: index = %d", __FUNCTION__, index);
@@ -958,7 +977,7 @@ void Execute_PositionGetTicket()
PrintFormat("%s: result = %u", __FUNCTION__, result); PrintFormat("%s: result = %u", __FUNCTION__, result);
#endif #endif
SEND_ULONG_RESPONSE(result, "PositionGetTicket"); SEND_ULONG_RESPONSE(result);
} }
void Execute_PositionsTotal() void Execute_PositionsTotal()
@@ -5537,7 +5556,7 @@ void Execute_TimeGMT()
void Execute_IndicatorRelease() void Execute_IndicatorRelease()
{ {
int indicator_handle; int indicator_handle;
GET_INT_VALUE(0, indicator_handle, "IndicatorRelease", "indicator_handle"); GET_INT_VALUE(0, indicator_handle, "indicator_handle");
#ifdef __DEBUG_LOG__ #ifdef __DEBUG_LOG__
PrintFormat("%s: indicator_handle = %d", __FUNCTION__, indicator_handle); PrintFormat("%s: indicator_handle = %d", __FUNCTION__, indicator_handle);
@@ -5557,7 +5576,7 @@ void Execute_GetLastError()
PrintFormat("%s: last_error = %d", __FUNCTION__, last_error); PrintFormat("%s: last_error = %d", __FUNCTION__, last_error);
#endif #endif
SEND_INT_RESPONSE(last_error, "GetLastError"); SEND_INT_RESPONSE(last_error);
} }
void Execute_Alert() void Execute_Alert()
@@ -5565,7 +5584,7 @@ void Execute_Alert()
string message; string message;
StringInit(message, 1000); StringInit(message, 1000);
GET_STRING_VALUE(0, message, "Alert", "message"); GET_STRING_VALUE(0, message, "message")
#ifdef __DEBUG_LOG__ #ifdef __DEBUG_LOG__
PrintFormat("%s: message = %s", __FUNCTION__, message); PrintFormat("%s: message = %s", __FUNCTION__, message);
@@ -5573,10 +5592,7 @@ void Execute_Alert()
Alert(message); Alert(message);
if (!sendVoidResponse(ExpertHandle, _error)) SEND_VOID_RESPONSE
{
PrintResponseError("Alert", _response_error);
}
} }
void Execute_ResetLastError() void Execute_ResetLastError()
@@ -5587,10 +5603,7 @@ void Execute_ResetLastError()
PrintFormat("%s: called", __FUNCTION__); PrintFormat("%s: called", __FUNCTION__);
#endif #endif
if (!sendVoidResponse(ExpertHandle, _error)) SEND_VOID_RESPONSE
{
PrintResponseError("ResetLastError", _response_error);
}
} }
void Execute_ChartOpen() void Execute_ChartOpen()
@@ -5644,6 +5657,24 @@ void Execute_ChartNext()
} }
} }
void Execute_ChartClose()
{
long chart_id;
GET_LONG_VALUE(0, chart_id, "chart_id")
#ifdef __DEBUG_LOG__
PrintFormat("%s: chart_id = %d", __FUNCTION__, chart_id);
#endif
bool result = ChartClose(chart_id);
#ifdef __DEBUG_LOG__
PrintFormat("%s: result = %s", __FUNCTION__, BoolToString(result));
#endif
SEND_BOOL_RESPONSE(result)
}
void Execute_ChartSymbol() void Execute_ChartSymbol()
{ {
long ChartId; long ChartId;
@@ -5717,6 +5748,28 @@ void Execute_ChartSaveTemplate()
ChartRedraw(ChartId); ChartRedraw(ChartId);
} }
void Execute_ChartWindowFind()
{
long chart_id;
string indicator_shortname;
StringInit(indicator_shortname, 200, 0);
GET_LONG_VALUE(0, chart_id, "chart_id")
GET_STRING_VALUE(1, indicator_shortname, "indicator_shortname")
#ifdef __DEBUG_LOG__
PrintFormat("%s: chart_id = %d, indicator_shortname = %s", __FUNCTION__, chart_id, indicator_shortname);
#endif
int result = ChartWindowFind(chart_id, indicator_shortname);
#ifdef __DEBUG_LOG__
PrintFormat("%s: result = %d", __FUNCTION__, result);
#endif
SEND_INT_RESPONSE(result)
}
void Execute_ChartGetString() void Execute_ChartGetString()
{ {
long ChartId; long ChartId;
@@ -5792,6 +5845,31 @@ void Execute_TerminalInfoDouble()
PrintResponseError("TerminalInfoDouble", _response_error); PrintResponseError("TerminalInfoDouble", _response_error);
} }
} }
void Execute_ChartId()
{
long id = ChartID();
#ifdef __DEBUG_LOG__
PrintFormat("%s: id = %d", __FUNCTION__, id);
#endif
SEND_LONG_RESPONSE(id)
}
void Execute_ChartRedraw()
{
long chart_id;
GET_LONG_VALUE(0, chart_id, "chart_id")
#ifdef __DEBUG_LOG__
PrintFormat("%s: chart_id = %d", __FUNCTION__, chart_id);
#endif
ChartRedraw(chart_id);
SEND_VOID_RESPONSE
}
void PrintParamError(string paramName) void PrintParamError(string paramName)
{ {