Occasionally error 130 in MT4

 

Hello all,

I have EA and I send oder BUY STOP or SELL STOP, but sometimes I get error 130. I use writting to log, so I can examine conditions when error occures.

In the log I have:

ERROR BUY STOP @ 1.94609, Ticket=-1, profit-target @ 1.94806, volume=0.63, error=130 - invalid stops

current ask=1.94588, bid=1.94566


It means, entry price is above current ask and bid, TP is above entry price, and StopLoss I use 0. For each prices in OrderSend methods parameters I use NormalizeDouble(value, Digits).

I have no clue where problem could be.

Any idea please ?

Thank you all for some help.

Alex


 
I use IC Markets and STOPLEVEL is 0
 
Alexik44: I have no clue where problem could be.

It means the entry price is too close to the Ask. Since stoplevel is zero your broker is a pass through, and you don't know the real value.

  1. Stop using a buy stop since you are essentially opening at market. Humans use them because they can't watch 24/5.5. EAs can — wait for the level and open.
  2. Or use the max of stoplevel and 2 pips for your minimum.
  3. Years ago when I tried pending orders, I also got strange errors. I think the server was comparing TP/SL to the current market. You might try setting the buy stop and then setting TP/SL.
 
William Roeder:

It means the entry price is too close to the Ask. Since stoplevel is zero your broker is a pass through, and you don't know the real value.

  1. Stop using a buy stop since you are essentially opening at market. Humans use them because they can't watch 24/5.5. EAs can — wait for the level and open.
  2. Or use the max of stoplevel and 2 pips for your minimum.
  3. Years ago when I tried pending orders, I also got strange errors. I think the server was comparing TP/SL to the current market. You might try setting the buy stop and then setting TP/SL.

Hello William, thank you very much for your replay. I probably will do it the way you wrote in 1). Just idea...is it possible to read STOPLEVEL immediately before entry and then adjust entry price ? Or if STOPLEVEL is zero, it will the same "zero" all the time ?

Thanks

Alex

 
Alexik44: Or if STOPLEVEL is zero, it will the same "zero" all the time ?

Yes

 
William Roeder:

Yes

OK. Thank you so much for your time and your replays.

Alex

Reason: