mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-18 05:08:11 +00:00
Position modify
This commit is contained in:
@@ -101,6 +101,7 @@ namespace MtApi5
|
|||||||
//CTrade
|
//CTrade
|
||||||
PositionClose = 64,
|
PositionClose = 64,
|
||||||
PositionOpen = 65,
|
PositionOpen = 65,
|
||||||
|
PositionModify = 6066,
|
||||||
//PositionOpenWithResult = 1065,
|
//PositionOpenWithResult = 1065,
|
||||||
|
|
||||||
//Backtesting
|
//Backtesting
|
||||||
|
|||||||
@@ -547,6 +547,20 @@ namespace MtApi5
|
|||||||
return SendCommand<bool>(Mt5CommandType.PositionClose, commandParameters);
|
return SendCommand<bool>(Mt5CommandType.PositionClose, commandParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Modifies existing position
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ticket">>Ticket of the position</param>
|
||||||
|
/// <param name="sl">Stop loss</param>
|
||||||
|
/// <param name="tp">Take profit</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool PositionModify(ulong ticket, double sl, double tp)
|
||||||
|
{
|
||||||
|
var commandParameters = new ArrayList { ticket, sl,tp };
|
||||||
|
|
||||||
|
return SendCommand<bool>(Mt5CommandType.PositionModify, commandParameters);
|
||||||
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
///Closes a position with the specified ticket.
|
///Closes a position with the specified ticket.
|
||||||
///</summary>
|
///</summary>
|
||||||
|
|||||||
@@ -552,6 +552,9 @@ int executeCommand()
|
|||||||
// case 1065: //PositionOpenWithResult
|
// case 1065: //PositionOpenWithResult
|
||||||
// Execute_PositionOpen(true);
|
// Execute_PositionOpen(true);
|
||||||
// break;
|
// break;
|
||||||
|
case 6066: //PositionModify
|
||||||
|
Execute_PositionModify();
|
||||||
|
break;
|
||||||
case 66: //BacktestingReady
|
case 66: //BacktestingReady
|
||||||
Execute_BacktestingReady();
|
Execute_BacktestingReady();
|
||||||
break;
|
break;
|
||||||
@@ -3255,6 +3258,41 @@ void Execute_MarketBookRelease()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Execute_PositionModify()
|
||||||
|
{
|
||||||
|
ulong ticket;
|
||||||
|
double sl;
|
||||||
|
double tp;
|
||||||
|
|
||||||
|
if (!getULongValue(ExpertHandle, 0, ticket, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("PositionModify", "ticket", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!getDoubleValue(ExpertHandle, 1, sl, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("PositionModify", "sl", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!getDoubleValue(ExpertHandle, 2, tp, _error))
|
||||||
|
{
|
||||||
|
PrintParamError("PositionModify", "tp", _error);
|
||||||
|
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CTrade trade;
|
||||||
|
bool ok = trade.PositionModify(ticket,sl,tp);
|
||||||
|
Print("command PositionModify: result = ", ok);
|
||||||
|
|
||||||
|
if (!sendBooleanResponse(ExpertHandle, ok, _response_error))
|
||||||
|
{
|
||||||
|
PrintResponseError("PositionModify", _response_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Execute_PositionOpen(bool isTradeResultRequired)
|
void Execute_PositionOpen(bool isTradeResultRequired)
|
||||||
{
|
{
|
||||||
string symbol;
|
string symbol;
|
||||||
|
|||||||
Reference in New Issue
Block a user