Implemented functions ChartIndicatorAdd and ChartIndicatorGet

This commit is contained in:
vdemydiuk
2018-03-24 21:45:35 +02:00
parent 1ffbba5ee3
commit 6ba6496e46
4 changed files with 86 additions and 3 deletions
+3 -3
View File
@@ -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,
+30
View File
@@ -1797,6 +1797,21 @@ namespace MtApi5
return SendCommand<bool>(Mt5CommandType.ChartNavigate, commandParameters);
}
///<summary>
///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.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="subWindow">Number of the chart subwindow. 0 denotes the main chart subwindow.</param>
///<param name="indicatorHandle">The handle of the indicator.</param>
///<returns>
///The function returns true in case of success, otherwise it returns false.
///</returns>
public bool ChartIndicatorAdd(long chartId, int subWindow, int indicatorHandle)
{
var commandParameters = new ArrayList { chartId, subWindow, indicatorHandle };
return SendCommand<bool>(Mt5CommandType.ChartIndicatorAdd, commandParameters);
}
///<summary>
///Removes an indicator with a specified name from the specified chart window.
///</summary>
@@ -1812,6 +1827,21 @@ namespace MtApi5
return SendCommand<bool>(Mt5CommandType.ChartIndicatorDelete, commandParameters);
}
///<summary>
///Returns the handle of the indicator with the specified short name in the specified chart window.
///</summary>
///<param name="chartId">Chart ID. 0 means the current chart.</param>
///<param name="subWindow">Number of the chart subwindow. 0 denotes the main chart subwindow.</param>
///<param name="indicatorShortname">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.</param>
///<returns>
///Returns an indicator handle if successful, otherwise returns INVALID_HANDLE.
///</returns>
public int ChartIndicatorGet(long chartId, int subWindow, string indicatorShortname)
{
var commandParameters = new ArrayList { chartId, subWindow, indicatorShortname };
return SendCommand<int>(Mt5CommandType.ChartIndicatorGet, commandParameters);
}
///<summary>
///Returns the short name of the indicator by the number in the indicators list on the specified chart window.
///</summary>
BIN
View File
Binary file not shown.
+53
View File
@@ -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;