Error 130 on OrderSend

 

Hello,

 I don't know why but I have in some trades (not all) the error 130 when I'm doing a backtest. The error 130 is invalid StopLoss but here is my OrderSend:

 

BuyTicket=OrderSend(Symbol(),OP_BUYSTOP,Units,BuyPrice,SlipPage,0,0, comment,MagicNumber,TimeCurrent()+expiration,clrYellow); 

 SellTicket=  OrderSend(Symbol(),OP_SELLSTOP,Units,SellPrice,SlipPage,0,0, comment,MagicNumber,TimeCurrent()+expiration,clrBlue);

 

Where is the error?

 Thank you very much 

 

sometimes it's OP_BUYLIMIT/OP_SELLLIMIT intead of OP_BUYSTOP/OP_SELLSTOP

https://www.metatrader5.com/en/terminal/help/trading/general_concept/order_types

 
Where is the error?
How BuyPrice & SellPrice calculated ?
 

Check this table for minimum price distances for pending orders: https://book.mql4.com/appendix/limits

You have to take into account stop level - minimum number of points your buy/sell price must be from current Bid/Ask  price.

You will need MarketInfo() function: 

Print("Stop level in points=",MarketInfo(Symbol(),MODE_STOPLEVEL));
Reason: