Download MetaTrader 5

Order Sort Issue in MT4 Build 941

To add comments, please log in or register
Searching on MQL5.community is performed in all sections. Try it!
Xiangdong Guo
3741
Xiangdong Guo 2015.12.22 15:39 
Usually, if I report some issues in ServiceDesk, I can't get response in time.
I have to post it here. Sigh...

In MT4 Build 941, I created some orders in a sequence "GBPUSD", "EURUSD", "AUDUSD", then I check them by "SELECT_BY_POS" immediately, the result like:
order#2, [AUDUSD]
order#1, [EURUSD]
order#0, [GBPUSD]

But if I restart MT4 terminial and check them again, the result become below:
order#2, [GBPUSD]
order#1, [EURUSD]
order#0, [AUDUSD] 

It seems, after restart, order had been sorted by alphabet.

Is it corrct?

  /*
  string symbol = "GBPUSD";
  int ticket = OrderSend(symbol, ORDER_TYPE_BUY, 1, SymbolInfoDouble(symbol, SYMBOL_ASK), 30, 0, 0);

  symbol = "EURUSD";
  ticket = OrderSend(symbol, ORDER_TYPE_BUY, 1, SymbolInfoDouble(symbol, SYMBOL_ASK), 30, 0, 0);

  symbol = "AUDUSD";
  ticket = OrderSend(symbol, ORDER_TYPE_BUY, 1, SymbolInfoDouble(symbol, SYMBOL_ASK), 30, 0, 0);
  //*/

  for (int i = 0; i < OrdersTotal(); i++) {
    if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      continue;

    PrintFormat("order#%d, [%s]", i, OrderSymbol());
  }

 

Xiangdong Guo
3741
Xiangdong Guo 2015.12.22 15:40  
Reproduced in MT4 Build 943.
Anyone investigate this issue?
Trinh Dat
37207
Trinh Dat 2015.12.22 15:52  
Orders open sort by time open ( order number )
Daniel Stein
25047
Daniel Stein 2015.12.22 15:53  
Xiangdong Guo:
Reproduced in MT4 Build 943.
Anyone investigate this issue?

What happens if you are counting down instead of counting up?

for(int iPos=OrdersTotal()-1; iPos>=0; iPos--) 
    if(OrderSelect(iPos,SELECT_BY_POS)

That's how i manage my orders and of course the position will change if one of those orders were closed. 

Marco vd Heijden
Moderator
4708
Marco vd Heijden 2015.12.22 16:02  

Totally normal

What is the issue ?

Xiangdong Guo
3741
Xiangdong Guo 2015.12.22 16:26  
Daniel Stein:

What happens if you are counting down instead of counting up?

That's how i manage my orders and of course the position will change if one of those orders were closed. 

If delete/close order in loop, I will use count down.

But if READ ONLY in loop, it's unnecessary.

Xiangdong Guo
3741
Xiangdong Guo 2015.12.22 16:28  
Trinh Dat:
Orders open sort by time open ( order number )
Yes, I remember it's sorted by order ticket number previous.
Xiangdong Guo
3741
Xiangdong Guo 2015.12.22 16:48  
Marco vd Heijden:

Totally normal

What is the issue ?

Oh man, did you think a simple logical question: Why second result was different with first result?
Alain Verleyen
Moderator
30755
Alain Verleyen 2015.12.22 17:56  
Xiangdong Guo:
Yes, I remember it's sorted by order ticket number previous.

There was never any guarantee on the order sorting. If you want a specific sorting, you have to code it.

It was always like this (which doesn't mean there is no change on the actual sorting).

Xiangdong Guo
3741
Xiangdong Guo 2015.12.22 18:22  
Alain Verleyen:

There was never any guarantee on the order sorting. If you want a specific sorting, you have to code it.

It was always like this (which doesn't mean there is no change on the actual sorting).

We made research ago (around 2010), it was sorted by ticket number.

Probably we are wrong, so it is time to clarify this concept.

Anyway, could MetaQuotes give us an official definition and add it into MQL4 Reference?

Alain Verleyen
Moderator
30755
Alain Verleyen 2015.12.22 18:40  
Xiangdong Guo:

We made research ago (around 2010), it was sorted by ticket number.

Probably we are wrong, so it is time to clarify this concept.

Anyway, could MetaQuotes give us an official definition and add it into MQL4 Reference?

You should contact the ServiceDesk if you want an official answer.
To add comments, please log in or register