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 . . .
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 . . .