OrderModify() return 130??

 

when an order sell Gbpusd :op = 2.0024 sl = 2.0054 profit = 1.9807 ask = 1.9959
,I modify sl to 1.9979 by orderModify() . And orderModify() return the value of Error= 130 (non-valid stoploss).

the code is as follows :


bool bSuccess = false ;
double _OrderStopLoss = OrderStopLoss() ;
double _Op = OrderOpenPrice() ;
if(OrderSelect(_Ticket1, SELECT_BY_TICKET, MODE_TRADES))
  {

  if( OrderType() == OP_BUY )
   {
  if( (Bid- _Op > 30 * Point) && (Bid - _OrderStopLoss > 25*Point) )
   {
    bSuccess = OrderModify(_Ticket1, _Op, Bid- 20 * Point,OrderProfit(),OrderExpiration(), Green ) ;
    OrderPrint() ;
    }
   }
   else
    {
   if( ( _Op - Ask > 30 * Point ) && ( _OrderStopLoss - Ask > 25*Point) )
   {
bSuccess = OrderModify( _Ticket1,_Op, Ask + 20 * Point,OrderProfit(), OrderExpiration(), Green ) ;
     OrderPrint() ;
   }

   }
   if( !bSuccess ) Print(" Modify this order failed for error #", GetLastError());
}
else Print("ERROR!!!!!") ;

can someone help me to debug this code .

thank you in advance !

 

FuLingQ:

you are using OrderProfit() in your OrderModify which is illegal because its in currency value while the TP should be in pip value relative to the current price. Use the same concept in the SL that you have for TP that should work.

Hope this help

Hazem


Reason: