Download MetaTrader 5
To add comments, please log in or register
Do you have Mac OS? Find out how to install MetaTrader on it!
Drazen Penic
2404
Drazen Penic 2014.04.24 16: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?

How?

Only thing that I found is function GlobalVariableSetOnCondition()

whroeder1
13602
whroeder1 2014.04.24 17: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
/
To add comments, please log in or register