Use PositionSelect to make sure there is a position opened with that ticket before trying to use PositionClose.
- Check what is written in the logs
- Use the debugger to control the values of the variables:
Code debugging: https://www.metatrader5.com/en/metaeditor/help/development/debug
Error Handling and Logging in MQL5: https://www.mql5.com/en/articles/2041
Tracing, Debugging and Structural Analysis of Source Code, scroll down to: "Launching and Debuggin": https://www.mql5.com/en/articles/272
Code debugging - Developing programs - MetaEditor Help
- www.metatrader5.com
MetaEditor has a built-in debugger allowing you to check a program execution step by step (by individual functions). Place breakpoints in the code...
Yashar Seyyedin #: Use PositionSelect to make sure there is a position opened with that ticket before trying to use PositionClose.
I don't know why, but
bool b = trade.PositionClose(symbol,ticket);
I was able to close with the code above. 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.
I am backtesting.
I've made it to the point where I have a position.
However, the position cannot be closed.
I have the ticket number.(#1)
The error number is 4753.
I would be happy if you could tell me.
...
...