Download MetaTrader 5

OrderSend error 130?

To add comments, please log in or register
Stephen Reynolds
9303
Stephen Reynolds  

With the following code I cant see why I'm getting order send error 130? When I test on my broker vipromarkets it is bug free but when I take it to auto validation it returns ordersend error 130.

Why is it the first code here works okay with no bugs :

         if(OrderType() == OP_BUY) 
         {         
            double trailStopPrice = Bid - (TrailingStop * _Point); 
            trailStopPrice = NormalizeDouble(trailStopPrice,_Digits);
            
            double currentStopLoss = NormalizeDouble(OrderStopLoss(),_Digits);  
            double currentProfit = Bid - OrderOpenPrice();
            double minProfit = MinimumProfit * _Point;

            if(trailStopPrice > currentStopLoss && currentProfit >= minProfit) 
            {                                                                
               bool modify = OrderModify(OrderTicket(),OrderOpenPrice(),trailStopPrice,OrderTakeProfit(),0);
            }
         }

But when I change it to the following I get the bug :

         if(OrderType() == OP_BUY) 
         {         
            double currentStopLoss = NormalizeDouble(OrderStopLoss(),_Digits);  
            double currentProfit = Bid - OrderOpenPrice();
            double minProfit = MinimumProfit * _Point;

            double perctrailstop = (TrailingStop / 100.0) * currentProfit;   
            double trailStopPrice = Bid - perctrailstop;       
            trailStopPrice = NormalizeDouble(trailStopPrice,_Digits);

            if(trailStopPrice > currentStopLoss && currentProfit >= minProfit) 
            {                                                                
               bool modify = OrderModify(OrderTicket(),OrderOpenPrice(),trailStopPrice,OrderTakeProfit(),0);
            }
         }


I'm sure the problem lies somewhere as outlined?

Alain Verleyen
Moderator
33777
Alain Verleyen  

There are at least a thousand topics about error 130 on this forum, did you try to find an answer ?

Check your stop is set according to the rules.

Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
  • book.mql4.com
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
To add comments, please log in or register