Theoretical question about order pool MOD_TRADES

 

We can look for a specific magic number by looping through MOD_TRADES.

for( int Loop = 0; Loop <= OrdersTotal() - 1 ; Loop ++ )
{
  OrderSelect( Loop , SELECT_BY_POS , MODE_TRADES );
  if( OrderMagicNumber() == Magic_Number ) 
  {
    // some interesting code
  }
}

 But what happens to that loop when you decide to delete or close one of the active tickets? Let’s say we have 5 pending orders: A to E. What happens if we decide to delete order C from within that loop? Does D become the third order in the loop or does it stay in fourth place?

 
burgie:

We can look for a specific magic number by looping through MOD_TRADES.

 But what happens to that loop when you decide to delete or close one of the active tickets? Let’s say we have 5 pending orders: A to E. What happens if we decide to delete order C from within that loop? Does D become the third order in the loop or does it stay in fourth place?

It changes position in the pool,  read this it will help you understand:  Loops and Closing or Deleting Orders
 

D*mn... why didn't I think of that? The answer is so logical :-)

I tried looking for such a posting, but wasn't able to find it. Thanks Raptor, that explains everything. Now I have to go through all my code to see where I did it wrong ;-\ 

Reason: