Iterating through orders and multiple EAs

 

Examples from help file and articles on this site recommend following procedure for iterating through active orders:

int total=OrdersTotal();
// write open orders
for(int pos=0;pos<total;pos++)
  {
   if(OrderSelect(pos,SELECT_BY_POS)==false) continue;
   // Do something with selected order
  }

What would happen if somebody else (e.g. EA on another Symbol) opens or closes order while program is in the middle of the above loop?

Opening new orders is not that much problematic because new order will be at the end of the list, but when some order is closed, if positions are updated, it could happen that the above loop skips an order.

Do you check for such events in your code?

How?

Only thing that I found is function GlobalVariableSetOnCondition()

 
  1. You must count down when closing/deleting or in the presence of other EAs that can. Loops and Closing or Deleting Orders - MQL4 forum Get in the habbit.
  2. Filter by magic number and pair
Reason: