Added PositionClose command to MT5 Api

This commit is contained in:
Wesley Teixeira
2016-09-13 09:03:55 -04:00
parent a11604503a
commit 9d48f74b29
3 changed files with 21 additions and 1 deletions
+11
View File
@@ -475,6 +475,17 @@ namespace MtApi5
{ {
return sendCommand<bool>(Mt5CommandType.OrderCloseAll, null); return sendCommand<bool>(Mt5CommandType.OrderCloseAll, null);
} }
///<summary>
///Closes a position with the specified ticket.
///</summary>
///<param name="ticket">Ticket of the closed position.</param>
public bool PositionClose(int ticket)
{
var commandParameters = new ArrayList { ticket};
return sendCommand<bool>(Mt5CommandType.PositionClose, commandParameters);
}
#endregion #endregion
#region Account Information functions #region Account Information functions
+2 -1
View File
@@ -100,6 +100,7 @@ namespace MtApi5
MarketBookAdd = 60, MarketBookAdd = 60,
MarketBookRelease = 61, MarketBookRelease = 61,
MarketBookGet = 62, MarketBookGet = 62,
OrderCloseAll = 63 OrderCloseAll = 63,
PositionClose = 64
} }
} }
+8
View File
@@ -227,6 +227,14 @@ int executeCommand()
sendBooleanResponse(ExpertHandle, retVal); sendBooleanResponse(ExpertHandle, retVal);
} }
break; break;
case 64: //PositionCloseBy
{
ulong ticket;
getULongValue(ExpertHandle, 0, ticket);
sendBooleanResponse(ExpertHandle, PositionClose(ticket));
}
break;
case 2: // OrderCalcMargin case 2: // OrderCalcMargin
{ {