mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-08 16:37:51 +00:00
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:
+17
-2
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user