Discussion of article "MQL5 Cookbook: How to Avoid Errors When Setting/Modifying Trade Levels" - page 2

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
Hello, when testing your expert advisor in strategy tester on GOLD I always obtained prompts Failed to open position - Invalid stops - no positions were opened. What was wrong? It was written to avoid this type of error?
I'm afraid we need some code in order to help you. Most probable thing is that the error does exist in your code. Check that your stops are larger than minimal allowed distance and that you did not, by any chance, misplace buy and sell stops. Also make sure your broker does allow specifing stops at position opening - some of them require to add stops only to existing positions (so called "market execution").
Hi I tested only expert advisor attached to the article How to avoid errors when setting/modifying trade level, without any change (Positionpropertiesplus). Instatrader platform by Instaforex. The functions in this advisor are written so, that if i set wrong stops parameters they are set to lowest allowed. So normaly should i obtain no error prompt - that is true by forex pairs. But by GOLD in this platform I obtain by each attempt of positionpropertiesplus EA to open position with stops, the error prompt invalid stops and no position in strategy tester was open. Is that the case you mentioned - problem with instatrader platform and broker? In GOLD symbol properties is written instant execution.
Here is example of function for stoploss calculation from mentioned EA - I used the EA attached to the mentioned article without any change, i only used GOLD instead of forex pairs:
...
Forum on trading, automated trading systems and testing trading strategies
Hello,
Please use the SRC button when you post code. Thank you.
This time, I edited it for you.
Hi I tested only expert advisor attached to the article How to avoid errors when setting/modifying trade level, without any change (Positionpropertiesplus). Instatrader platform by Instaforex. The functions in this advisor are written so, that if i set wrong stops parameters they are set to lowest allowed. So normaly should i obtain no error prompt - that is true by forex pairs. But by GOLD in this platform I obtain by each attempt of positionpropertiesplus EA to open position with stops, the error prompt invalid stops and no position in strategy tester was open. Is that the case you mentioned - problem with instatrader platform and broker? In GOLD symbol properties is written instant execution.
Here is example of function for stoploss calculation from mentioned EA - I used the EA attached to the mentioned article without any change, i only used GOLD instead of forex pairs:
Once more to the calculation of stops (SL/TP) in attached EA - they are calculated correctly only by instruments where symbol point = symbol tick size. That is not the case by GOLD.
Stops must be in this case (by GOLD) corrected to valid symbol ticksize, otherwise you obtain error prompt - invalid stops .
So the error prompts by GOLD are not result of market execution. EA needs a bit correction in calculation of SL/TP, if you want to use it with GOLD.
What about closing a position? If there are conditions (signal) for closing positions in the Expert Advisor, how to do it, where can I see such examples?