Hayseed,
I'm not an expert programmer by any means but I was having trouble on my EAs with closing all orders until I made the for-loop count down instead of up...something like this...
for(Counter = OrdersTotal()-1; Counter >= 0; Counter--)
It's worth a look, I guess.
Glen