Modified the ObjectCreate such that it can take up to 30 anchor points (maximum amount of anchor points in mql5). The MtApi5.mq5 has been updated to cope with the added parameters. The MtApi5.ex5 has been rebuilt.

This commit is contained in:
Florian Wilhelm
2019-03-07 00:03:05 +01:00
parent f01ec01a5f
commit bb4ac426cd
3 changed files with 64 additions and 14 deletions
+17 -2
View File
@@ -2086,9 +2086,24 @@ namespace MtApi5
///<param name="nwin">Number of the chart subwindow. 0 means the main chart window. The specified subwindow must exist, otherwise the function returns false.</param>
///<param name="time">The time coordinate of the first anchor.</param>
///<param name="price">The price coordinate of the first anchor point.</param>
public bool ObjectCreate(long chartId, string name, ENUM_OBJECT type, int nwin, DateTime time, double price)
///<param name="listOfCoordinates">List of further anchor points (tuple of time and price).</param>
public bool ObjectCreate(long chartId, string name, ENUM_OBJECT type, int nwin, DateTime time, double price, List<Tuple<DateTime, double>> listOfCoordinates = null)
{
var commandParameters = new ArrayList { chartId, name, (int)type, nwin, Mt5TimeConverter.ConvertToMtTime(time), price };
//Count the additional coordinates
int iAdditionalCoordinates = (listOfCoordinates != null) ? listOfCoordinates.Count() : 0;
if(iAdditionalCoordinates > 29)
{
throw new ArgumentOutOfRangeException("listOfCoordinates", "The maximum amount of coordinates in 30.");
}
int nParameter = 6 + iAdditionalCoordinates * 2;
var commandParameters = new ArrayList { nParameter, chartId, name, (int)type, nwin, Mt5TimeConverter.ConvertToMtTime(time), price };
foreach (Tuple<DateTime, double> coordinateTuple in listOfCoordinates)
{
commandParameters.Add(Mt5TimeConverter.ConvertToMtTime(coordinateTuple.Item1));
commandParameters.Add(coordinateTuple.Item2);
}
return SendCommand<bool>(Mt5CommandType.ObjectCreate, commandParameters);
}