Download MetaTrader 5

OrderModify Error 130

To add comments, please log in or register
Forex Trader
114314
Forex Trader  
I am repeatedly receiving "OrderModify Error 130" in the Strategy Tester journal and cannot resolve it. I believe it has something to do with the trailing stops that are being placed in the code below:

if(OrderType()==OP_BUY)   // long position is opened
           {
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else // go to short position
           {
            // check for trailing stop
            if(TrailingStop>0)              
              {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
        }
   }
  return(0);
  }



Any help to resolve this error is greatly appreciated.

Forex Trader
114314
Forex Trader  
Too close stops. Your TrailingStop value is less than freeze level. To know freeze level use MarketInfo function
Ali Raza
582
Ali Raza  

I have the same problem here. i used many settings but it still giving me errors.

so i used

 

bool modifySL;

   modifySL=OrderModify(OrderTicket(),OrderOpenPrice(),nStopLoss,OrderTakeProfit(),OrderExpiration(),CLR_NONE);

   if(!modifySL)

    {

     Print("StopLoss Price is not modify");

     }

     else

     {

     modifySL=true;

     }

 and now i receiving Occasionally & very low errors.

But Forex Trader is right we need to use Trailing or SL on Freeze level. I think our trailing and SL prices is too close when we receive these errors. 

To add comments, please log in or register