OrderCheck() failure

To add comments, please log in or register
Code2219 or probably 2319
424
Code2219 or probably 2319  
Hi, this piece of code , always leads to the same error.
the ModifyReq is filled just as Trade.mqh is filling it before sending a modification order.

// getting position data here.... symbol, TP, ticket...
// and all values are checked.
// pos_symbol != ""
// long pos_ticket = PositionGetInteger...
// new_suggested_SL = pos_OpenPrice ± (N * symbol_point) , N is integer


MqlTradeRequest ModifyReq;
MqlTradeCheckResult ModifyRes;

ModifyReq.action = TRADE_ACTION_SLTP;
ModifyReq.position = pos_ticket;
ModifyReq.symbol = pos_symbol;
ModifyReq.magic = magic;
ModifyReq.sl = new_suggested_SL;        // calculated above
ModifyReq.tp = pos_TakeP;               // current TP price of position

if(OrderCheck(ModifyReq, ModifyRes))    // never evaluated to be true !
{
        m_trade.PositionModify(pos_ticket, new_suggested_SL, pos_TakeP);        // only SL is adjusted
        if(m_trade.ResultRetcode()==10009) MP_SL_adjusts++;
}
else Print("Order_Check_RetCode = ", ModifyRes.retcode); // which is always equal to 10013 : TRADE_RETCODE_INVALID

when this 10013 retcode is returned ? and what does it mean a trade being INVALID ?

Code2219 or probably 2319
424
Code2219 or probably 2319  
Code2219 or probably 2319:
Hi, this piece of code , always leads to the same error.
the ModifyReq is filled just as Trade.mqh is filling it before sending a modification order.

when this 10013 retcode is returned ? and what does it mean a trade being INVALID ?

Sorry, my bad.
I was not doing it the same way trade.mqh is filling the request structure.
for anyone making my mistake when using ordercheck() function before doing trade operations, elements of the request structure must be initiated to zero, or just ZeroMemory()ed.


To add comments, please log in or register