Why not . . .
Not tested or tried to compile it . . .
Sneaky! You are going back to the beginning of the loop when you find the valid trade. That is clever.
I would never compare to #define'd symbols with greater than or lesser than. They are symbolic forms and relying on their actual values is poor programming practice. Gain 1 point for sneaky trick and lose two for using greater/lesser comparison on #defined symbols :-)
Sneaky! You are going back to the beginning of the loop when you find the valid trade. That is clever, although you would want to use
pos= OrdersTotal()-1; <<<
You check in one time not only if there are open buys and/or sells (nOpenOrders)
but also the total with pending include (EAtrades)
Only when nOpenOrders > 0 and when the total trades > nOpenOrders you have to delete the pending
In that case the check is done atonce
If all pending are deleted the next tick this loop for deleting pending will not be done again.....
I think it is faster...
Agree nice the coding of RaptorUK fine solution for it.....