This problem is persisting. Any ideas will be appreciated. Thanks
enivid:
I don't see where do you check the new SL against the current market price in your code?
I don't see where do you check the new SL against the current market price in your code?
It was here...
trailing_stop=PositionGetDouble(POSITION_PRICE_CURRENT)-MathMax(StopFreeze(Ticker),trailing_points);
the new trailing stop price had to be below the the position's current price. Actually I had even tried the Bid price (in place of position current price), but I was still getting errors.
What's StopFreeze(Ticker)? You have to compare the new SL to the current price (Bid for LONG) - it shouldn't be closer than SYMBOL_TRADE_STOPS_LEVEL to the current price.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
- www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
enivid:
What's StopFreeze(Ticker)? You have to compare the new SL to the current price (Bid for LONG) - it shouldn't be closer than SYMBOL_TRADE_STOPS_LEVEL to the current price.
What's StopFreeze(Ticker)? You have to compare the new SL to the current price (Bid for LONG) - it shouldn't be closer than SYMBOL_TRADE_STOPS_LEVEL to the current price.
Happy new year.
This
StopFreeze(Ticker)
was the maximum between the stops level which you have mentioned above, and the freeze level. 'Ticker' is just the string for the symbol name. Like I said above I was trying Bid price before and was still getting errors. I suspect its a bug in the CTrade class. I had to rewrite the trade class.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
My EA needs to modify its position SL but sometimes gets the invalid stops error for long positions. The short positions are always modified without any problem.
Here is my source..
Is there a better way of implementing this?