Thread: MQL4 Learning
View Single Post
  #363 (permalink)  
Old 04-03-2008, 10:08 AM
ys16 ys16 is offline
Junior Member
 
Join Date: Mar 2008
Posts: 8
ys16 is on a distinguished road
Quote:
Originally Posted by jlpi View Post
I know why
It is because you use the loop on orders the following way
for(int i=0;i<OrdersTotal();i++)

Then think about what that does. every time you close an order the OrdersTotal() decreases and on the other side i increases. So no surprise that every time half of the orders only are closed as the interval is reduced on each extremity for every iteration.

the correct loop is
for(int i=OrdersTotal()-1; i>=0;i--)
Thank you very very much!
yours should work!

I will try now.
Reply With Quote