In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading)
you must count down when closing/deleting/modifying in a position loop. Loops and Closing or Deleting Orders - MQL4 forum But since you want to close in order, you can't use a position loop.

In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading) you must count down when closing/deleting/modifying in a position loop. Loops and Closing or Deleting Orders - MQL4 forum But since you want to close in order, you can't use a position loop.