OrderSend() failing with code 130 - invalid stops

 

Guys this has me stumped. In fact it is making me crazy.

At times, my OrderSend() requests will be repeatedly rejected with error 130 "invalid stops". But my stops are not very close to the open price at all. Here is an example:

EURUSD, Sell, openprice (bid) = 1.3150, stoploss=1.3180, takeprofit=1.3060

Immediately before placing the order I got the bid value using:

RefreshRates();
bid = MarketInfo(Symbol(),MODE_BID);

and then calculated the stops from there, so all of the values should be fresh.

HELP please?

Lee

 
  1. Use this and you would have likely found your answer.
 
WHRoeder:
  1. Use this and you would have likely found your answer.

Okay, the SRC thing will definitely be helpful. But that "answer" links to a post about using an ECN broker, and I don't think that's relevant.
 
leecallen:

Immediately before placing the order I got the bid value using:

RefreshRates();
bid = MarketInfo(Symbol(),MODE_BID);


You don't need the RefreshRates() it is pointless, RefreshRates only applies to predefined variables . . . . from the documentation " Refreshing of data in pre-defined variables and series arrays. " predefined variables are, Bid, Ask, Open, Close, etc so using MarketInfo means you don't have to call RefreshRates.

Your issue is probably an ECN Broker issue . . . do some reading ECN

 
leecallen:

Okay, the SRC thing will definitely be helpful. But that "answer" links to a post about using an ECN broker, and I don't think that's relevant.
Check your Freezelevel and Stoplevel using MarketInfo . . . . write a simple script to do it, Comment it to screen. If they are both 0.0 then your Broker is most likely an ECN Broker . . . if it is then you need to send your order with TP & SL set to 0.0 then do an order modify to set TP & SL. Read some of the posts shown by the link I posted.
 
RaptorUK:
Check your Freezelevel and Stoplevel using MarketInfo . . . . write a simple script to do it, Comment it to screen. If they are both 0.0 then your Broker is most likely an ECN Broker . . . if it is then you need to send your order with TP & SL set to 0.0 then do an order modify to set TP & SL. Read some of the posts shown by the link I posted.

Thanks Raptor - the Stoplevel pointed me in the right direction. It's running around 30 pips, which is much higher than I anticipated. So I have deleted the RefreshRates() and added code to ensure my stop-loss level conforms to the MODE_STOPLEVEL. There doesn't seem to be a MarketInfo() mode for take-profit, does it also use MODE_STOPLEVEL ?
 
leecallen:

Thanks Raptor - the Stoplevel pointed me in the right direction. It's running around 30 pips, which is much higher than I anticipated. So I have deleted the RefreshRates() and added code to ensure my stop-loss level conforms to the MODE_STOPLEVEL. There doesn't seem to be a MarketInfo() mode for take-profit, does it also use MODE_STOPLEVEL ?
There isn't one for TP, and STOP_LEVEL isn't just relevant to SL, you must not enter too close to the current price, take a look at FREEZE_LEVEL also . . . . read and take some time to understand the info here, it will explain all : Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
 
leecallen:

Thanks Raptor - the Stoplevel pointed me in the right direction. It's running around 30 pips, which is much higher than I anticipated. So I have deleted the RefreshRates() and added code to ensure my stop-loss level conforms to the MODE_STOPLEVEL. There doesn't seem to be a MarketInfo() mode for take-profit, does it also use MODE_STOPLEVEL ?
  1. StopLevel is for both
  2. On a 5 digit broker a point is not a pip, your stoplevel is 30 meaning 3.0 pips on a 5 digit broker.
  3. You don't have to call RefreshRates() except after calls that take time. (Sleep, server calls.)