Download MetaTrader 5

deleting all pending if found one working order - page 2

To add comments, please log in or register
dabbler
1102
dabbler  
RaptorUK:

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 :-)

Simon Gniadkowski
Moderator
18045
Simon Gniadkowski  
dabbler:

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

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 :-)

<<< I wondered about that, wasn't sure if it would then be decremented by the for loop next run through . . . making it OrdersTotal() - 2
dabbler
1102
dabbler  
deVries:


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

This sort of test takes very little computational effort so I wouldn't bother. I prefer Raptor's solution, not just because it is faster, but also because it removes a lot of duplicated code; time to code and debug is part of the total cost of the EA.
Tjipke de Vries
6412
Tjipke de Vries  

Agree nice the coding of RaptorUK fine solution for it.....

dabbler
1102
dabbler  
RaptorUK:
<<< I wondered about that, wasn't sure if it would then be decremented by the for loop next run through . . . making it OrdersTotal() - 2
I think you are right; I'm just being a dumb arse tonight :-)
12
To add comments, please log in or register