Order cannot be closed.

 

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.

...

Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

Code button in editor

Hover your mouse over your post and select "edit" ... 

...

 

Use PositionSelect to make sure there is a position opened with that ticket before trying to use PositionClose.

 
  1. Check what is written in the logs
  2. 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.