Skip to content

Commit ae20ee9

Browse files
authored
Add files via upload
1 parent a5d61cf commit ae20ee9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

MT5socketAPI/Terminal.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,39 @@ public List<Position> GetPendingOrders()
416416

417417
}
418418

419+
/// <summary>
420+
/// Get Information from an opened order
421+
/// </summary>
422+
/// <returns>Opened order</returns>
423+
public Position getOrderInfo(long ticket)
424+
{
425+
try
426+
{
427+
JObject json_cmd = new JObject();
428+
json_cmd["MSG"] = "ORDER_INFO";
429+
json_cmd["TICKET"] = ticket;
430+
JObject res = SendCommand(json_cmd);
431+
432+
if (res["ERROR_ID"].ToString() == "0")
433+
{
434+
List<Position> opened = JsonConvert.DeserializeObject<List<Position>>(res["OPENED"].ToString());
435+
if (opened.Count > 0)
436+
{
437+
return opened.First();
438+
}
439+
else return new Position();
440+
}
441+
else
442+
{
443+
throw new Exception("Error with the GetOpenedOrders command. ERROR_ID: " + res["ERROR_ID"] + " ERROR_DESCRIPTION: " + res["ERROR_DESCRIPTION"]);
444+
}
445+
}
446+
catch (Exception)
447+
{
448+
throw;
449+
}
450+
}
451+
419452
/// <summary>
420453
/// Get Opened Positions
421454
/// </summary>

0 commit comments

Comments
 (0)