Why are you printing/Alerting the error if there is none ? please read the Thread I gave a link to . . . check the return value from the OrderSend(), OrderModify(), OrderClose() etc. if the return value tells you that the operation failed then print the error.
If the orders are being closed before you think they should be closed print the variables that you use to decide to close or not close and see if they are what you expect . . .
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I'd like to know, but error is: 0
If the orders are being closed before you think they should be closed print the variables that you use to decide to close or not close and see if they are what you expect . . .