Invalid stops error 130 with SL = 0 and TP = 0. WHY??

 

I have an EA that places BuyLimit and SellLimit trades. Most of the time there is no problem and the trades are placed successfully. But every now and then there is a trades that refuses to go through and ndlessly giving an "invalid stops" error. The problem is I define NO specific SL or TP. They are both set at "0".

This is so frustrating! Can anybody help me?

 
Ernest Klokow: I have an EA that places BuyLimit and SellLimit trades. Most of the time there is no problem and the trades are placed successfully. But every now and then there is a trades that refuses to go through and ndlessly giving an "invalid stops" error. The problem is I define NO specific SL or TP. They are both set at "0". This is so frustrating! Can anybody help me?
You have to consider the contract specifications for the Freeze Level and Stops Level. Please read the following ... Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
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
 
  1. Ernest Klokow: I have an EA that places BuyLimit and SellLimit trades. 

    There is no need to create pending orders in code.

    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

      Don't worry about it unless you're scalping M1 or trading news.

    2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

  2. Ernest Klokow: Can anybody help me?

    Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.

    We can't see your broken code.

    With the information you've provided — we can only guess. Which Fernando already did.

 

Thanks for that info. I inserted the following code and so far I have had no errors. Hold thumbs!

 if(Ask - LimitBuyPrice < StopLevel * _Point || LimitBuyPrice >= Ask) LimitBuyPrice = Ask - (StopLevel * _Point);
 if(LimitSellPrice - Ask < StopLevel * _Point || LimitSellPrice <= Bid) LimitSellPrice = Bid + (StopLevel * _Point);