SELECT_BY_POS: Is it the newest or the oldest order?

 

Hi, is the ticketnumber the newest or the oldest ticket of the orders?

and how about  

for(int i=ordersTotal()-1; i>=0; i--)

Thank you.

for (i=0; i< OrdersTotal(); i++){
   if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)
   ticketnumber = OrderTicket();
}

Improperly formatted code edited by moderator. Please use the CODE button (Alt-S) when inserting code.

Code button in editor

PS: Sorry I'm not a programmer, I just want to know which order is newer selected by pos, 0 or 1?

 
Changhua Lin:

Hi, is the ticketnumber the newest or the oldest ticket of the orders?

Position 0 is the newest opened trade.

Please read the help pages in metaeditor OR the link near top of every page on this website, "Documentation".

 
Changhua Lin: Hi, is the ticketnumber the newest or the oldest ticket of the orders? ... Sorry I'm not a programmer, I just want to know which order is newer selected by pos, 0 or 1?
My understanding is there's no guarantee the orders are returned in time order so you need to compare OrderOpenTime() of each order.
 
Changhua Lin:
Hi, is the ticketnumber the newest or the oldest ticket of the orders?

You can't know for sure. As mentioned above, check the order opening time.

Changhua Lin: and how about

for(int i=ordersTotal()-1; i>=0; i--)

This way is better and preferable.