Download MetaTrader 5
To add comments, please log in or register
Millions of traders download codes from MQL5 library. Share your app with them!
gobya
13
gobya 2014.06.12 02:02 

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 

qjol
3243
qjol 2014.06.12 02:24  

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

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

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.06.12 02:26  
Where is the error?
How BuyPrice & SellPrice calculated ?
Drazen Penic
2408
Drazen Penic 2014.06.12 07:50  

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));
/
To add comments, please log in or register