My stoploss and take profit will not move

 
void LongPositionMoveSLTP()
{
double      slb = NormalizeDouble(iEnvelopeUp[1],_Digits);
double      tpb = NormalizeDouble(iEnvelopeBtm[1],_Digits);
 
   MqlTradeRequest mrequest;                            
   MqlTradeResult mresult;   
   ZeroMemory(mrequest);
   ZeroMemory(mresult);

   if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)

      {
       mrequest.action=TRADE_ACTION_SLTP;
       mrequest.sl = slb;   
       mrequest.tp = tpb;
       OrderSend(mrequest,mresult);   
      }
      
It gives me the error: 2014.05.17 03:18:49    Core 1    2014.01.31 00:00:00   failed modify buy 0.00  sl: 0.00000, tp: 0.00000 -> sl: 1.35017, tp: 1.37186 [Invalid request]

The order is a pending order that has been triggered with stoploss and takeprofit already set

From order to position the position has no SL or TP. 

But as you can see there is no value???

 
wehsnim:
It gives me the error: 2014.05.17 03:18:49    Core 1    2014.01.31 00:00:00   failed modify buy 0.00  sl: 0.00000, tp: 0.00000 -> sl: 1.35017, tp: 1.37186 [Invalid request]

The order is a pending order that has been triggered with stoploss and takeprofit already set

From order to position the position has no SL or TP. 

But as you can see there is no value???

Where did you set the position to modify ?

SL & TP Modification

Trade order to modify the StopLoss and/or TakeProfit price levels. It requires to specify the following 4 fields:

action

symbol

sl

tp

I strongly suggest you to check the return value of OrderSend() and to process error in your code.

 
angevoyageur:

Where did you set the position to modify ?

SL & TP Modification

I strongly suggest you to check the return value of OrderSend() and to process error in your code.

I read your post. Went to the documentation.

Added : mrequest.symbol=Symbol();

The function came together beautifully.

I am now correcting the OrderSend Function..

Thank you for the help. :)

 
wehsnim:

I read your post. Went to the documentation.

Added : mrequest.symbol=Symbol();

The function came together beautifully.

I am now correcting the OrderSend Function..

Thank you for the help. :)

You are welcome.
Reason: