OrderModify not working confused

 

what exactly is wrong with my OrderModify's TP/SL I've been reading on forums and the docs but I really don't get this part (it might be my dyslexia :/).

Ive tried other values close to these but only ever get 'OrderModify error 130' or 'OrderModify error 1'...

May I have some help?

OrderSend(Symbol(),OP_BUY,0.01,Ask,1,Ask-5.0,Ask+0.09,"buy",RR,0,Green);
OrderSend(Symbol(),OP_SELL,0.01,Bid,1,Bid+5.0,Bid-0.09,"sell",RR,0,Red);

if(OrdersTotal()>0){for(int i=1;i<=OrdersTotal();i++){if(OrderSelect(i-1,SELECT_BY_POS)==true){
         
         double E=(OrderProfit())/OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE);
         
         if((OrderType()==OP_BUY)&&(E<=0.06)&&(OrderSymbol()==Symbol())){
            if(c1=="G"){OrderModify(
                                    OrderTicket(),
                                    OrderOpenPrice(),
                                    Ask-0.05,
                                    OrderTakeProfit(),
                                    0,
                                    CLR_NONE
                                    );}}
         if((OrderType()==OP_SELL)&&(E<=0.06)&&(OrderSymbol()==Symbol())){
            if(c1=="R"){OrderModify(
                                    OrderTicket(),
                                    OrderOpenPrice(),
                                    Bid+0.05,
                                    OrderTakeProfit(),
                                    0,
                                    CLR_NONE
                                    );}}
      }}}
 
benzmuircroft:

what exactly is wrong with my OrderModify's TP/SL I've been reading on forums and the docs but I really don't get this part (it might be my dyslexia :/).

Ive tried other values close to these but only ever get 'OrderModify error 130' or 'OrderModify error 1'...

May I have some help?


What is your Symbol() ??

OrderSend(Symbol(),OP_BUY,0.01,Ask,1,Ask-5.0,Ask+0.09,"buy",RR,0,Green); //SL -5 for a Symbol() like EURUSD will fail
OrderSend(Symbol(),OP_SELL,0.01,Bid,1,Bid+5.0,Bid-0.09,"sell",RR,0,Red);

Also what is RR ??


if(OrdersTotal()>0){for(int i=1;i<=OrdersTotal();i++){if(OrderSelect(i-1,SELECT_BY_POS)==true){
Why not make it a habit counting down trades when you check them.....
double E=(OrderProfit())/OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE);

Don't understand why you are using this for getting to know if you modify or not

when no profit or loss always < 0.06 that is already when you open a trade

         if((OrderType()==OP_BUY)&&(E<=0.06)&&(OrderSymbol()==Symbol())){
            if(c1=="G"){OrderModify(
                                    OrderTicket(),
                                    OrderOpenPrice(),
                                    Ask-0.05,
                                    OrderTakeProfit(),
                                    0,
                                    CLR_NONE
                                    );}}

Don't kno what c1=="G" means but you don't check the value of OrderStopLoss() when you modifie the trade

So the value can be modified up/down and equal (modifie error 1)

 

check

MarketInfo(Symbol(), MODE_STOPLEVEL);
MarketInfo(Symbol(), MODE_FREEZELEVEL);