Iterating through orders and multiple EAs

Back to topics list To post a new topic, please log in or register
drazen64 2014.04.24 18:24

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?


Only thing that I found is function GlobalVariableSetOnCondition()

WHRoeder 2014.04.24 19:03 #
  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
Back to topics list  

To add comments, please log in or register