Hello guys,
can you help me with this problem? I always receive an invalid request (error 4756 invalid stops) when the SL should be moved to breakeven. But in the log file I can see that the SL is correct.
No idea? :(
Learn how to track possible errors!
Check the return code, print the relevant variables like SL, TP, ask and bid ...
Learn to use the debugger: https://www.mql5.com/en/articles/654.
- www.mql5.com
Learn how to track possible errors!
Check the return code, print the relevant variables like SL, TP, ask and bid ...
Learn to use the debugger: https://www.mql5.com/en/articles/654.
Thanks for your advice!
My problem is that I am not sure about the code itself. The trade management is so different from MQL4 (positions, deals...) and I didn't find any code which modifies a stoploss in a running trade which I could learn from.
Your code shows no signs of you checking for Stops Level. Always check the broker's contract specifications, like the Stops Levels and Freeze Levels.
Also your logic seems strange ...
bid > op + ( op - sl ) ... is equivalent to ... bid > 2 * op - sl ask < op - ( sl - op ) ... is equivalent to ... ask < 2 * op - sl
Thanks for your advice!
My problem is that I am not sure about the code itself. The trade management is so different from MQL4 (positions, deals...) and I didn't find any code which modifies a stoploss in a running trade which I could learn from.
Then use MT4 style for MT5 https://www.mql5.com/ru/code/16006
@all thanks for your help!
FYI: I just needed to add the magic number as a parameter and then my code worked. I didn't know that this magic number is needed.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello guys,
can you help me with this problem? I always receive an invalid request (error 4756 invalid stops) when the SL should be moved to breakeven. But in the log file I can see that the SL is correct.