Download MetaTrader 5

Order Sort Issue in MT4 Build 941

To add comments, please log in or register
Xiangdong Guo
3906
Xiangdong Guo  
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
3906
Xiangdong Guo  
Reproduced in MT4 Build 943.
Anyone investigate this issue?
Trinh Dat
38304
Trinh Dat  
Orders open sort by time open ( order number )
Daniel Stein
29923
Daniel Stein  
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
4994
Marco vd Heijden  

Totally normal

What is the issue ?

Xiangdong Guo
3906
Xiangdong Guo  
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
3906
Xiangdong Guo  
Trinh Dat:
Orders open sort by time open ( order number )
Yes, I remember it's sorted by order ticket number previous.
Xiangdong Guo
3906
Xiangdong Guo  
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
32062
Alain Verleyen  
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
3906
Xiangdong Guo  
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
32062
Alain Verleyen  
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