mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-27 18:47:55 +00:00
Merge pull request #61 from Tr4Dr/master
Updated PositionClose function and a fixed warning (MT5)
This commit is contained in:
@@ -497,9 +497,10 @@ namespace MtApi5
|
||||
///Closes a position with the specified ticket.
|
||||
///</summary>
|
||||
///<param name="ticket">Ticket of the closed position.</param>
|
||||
public bool PositionClose(int ticket)
|
||||
///<param name="deviation">Maximal deviation from the current price (in points).</param>
|
||||
public bool PositionClose(ulong ticket, ulong deviation = ulong.MaxValue)
|
||||
{
|
||||
var commandParameters = new ArrayList { ticket};
|
||||
var commandParameters = new ArrayList { ticket, deviation };
|
||||
|
||||
return SendCommand<bool>(Mt5CommandType.PositionClose, commandParameters);
|
||||
}
|
||||
|
||||
+13
-11
@@ -279,12 +279,14 @@ int executeCommand()
|
||||
|
||||
case 64: //PositionClose
|
||||
{
|
||||
int ticket;
|
||||
ulong ticket;
|
||||
ulong deviation;
|
||||
CTrade trade;
|
||||
|
||||
getIntValue(ExpertHandle, 0, ticket);
|
||||
|
||||
sendBooleanResponse(ExpertHandle, trade.PositionClose(ticket));
|
||||
|
||||
getULongValue(ExpertHandle, 0, ticket);
|
||||
getULongValue(ExpertHandle, 1, deviation);
|
||||
|
||||
sendBooleanResponse(ExpertHandle, trade.PositionClose(ticket, deviation));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1906,7 +1908,7 @@ string OnRequest(string json)
|
||||
return response;
|
||||
}
|
||||
|
||||
string CreateErrorResponse(int code, string message)
|
||||
string CreateErrorResponse(int code, string message_er)
|
||||
{
|
||||
JSONValue* jsonError;
|
||||
if (code == 0)
|
||||
@@ -1914,13 +1916,13 @@ string CreateErrorResponse(int code, string message)
|
||||
else
|
||||
jsonError = new JSONNumber((long)code);
|
||||
|
||||
JSONObject *joResponse = new JSONObject();
|
||||
JSONObject *joResponse = new JSONObject();
|
||||
joResponse.put("ErrorCode", jsonError);
|
||||
joResponse.put("ErrorMessage", new JSONString(message));
|
||||
joResponse.put("ErrorMessage", new JSONString(message_er));
|
||||
|
||||
string result = joResponse.toString();
|
||||
delete joResponse;
|
||||
return result;
|
||||
string result = joResponse.toString();
|
||||
delete joResponse;
|
||||
return result;
|
||||
}
|
||||
|
||||
string CreateSuccessResponse(string responseName, JSONValue* responseBody)
|
||||
|
||||
Reference in New Issue
Block a user