Hi,
This is a history for 3 hours of trading, lodgement + result.
It looks like orders in the history are ordered by their close time. In this case such behaviour is normal.
Thank you
... today I found that function OrderSelect(1,SELECT_BY_POS,MODE_HISTORY) does not return the first order from the history, but returns order from the middle of the history.
There is a possibility that the order of entries in history is not reliable (i.e., not sorted by Open Time). See here and here. So, you may need to manually sort the entries in history by OrderOpenTime() to the achieve the solution you are looking for.
Of course it doesn't. It never did. Position ZERO is the first in the list.
If you want the earliest closed order, sort the list: Order History sort by closing date - MQL4 forum

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I use "MT4, Build 482", today I found that function OrderSelect(1,SELECT_BY_POS,MODE_HISTORY) does not return the first order from the history, but returns order from the middle of the history.
OrderSelect(1,SELECT_BY_POS,MODE_HISTORY);
Print("First Order #= ",OrderTicket());
The Result is:
2013.04.26 15:51:06 test USDCHF,M30: First Order #= 178555092
But result must be : 178532001
I would appreciate it very much if you could clarify if this is a bug or I am expecting too much ?
I output ticket number of 3 orders, but it did not became more clear ...
OrderSelect(1,SELECT_BY_POS,MODE_HISTORY);
Print("First Order #= ",OrderTicket());
OrderSelect(2,SELECT_BY_POS,MODE_HISTORY);
Print("Second Order #= ",OrderTicket());
OrderSelect(3,SELECT_BY_POS,MODE_HISTORY);
Print("Third Order #= ",OrderTicket());
2013.04.26 15:59:16 test USDCHF,M30: Third Order #= 178555065
2013.04.26 15:59:16 test USDCHF,M30: Second Order #= 178555081
2013.04.26 15:59:16 test USDCHF,M30: First Order #= 178555092
index 0 - is a deposite.
OrderSelect(0,SELECT_BY_POS,MODE_HISTORY);
Print("0 Order #= ",OrderTicket());
2013.04.26 16:32:29 test USDCHF,M30: 0 Order #= 178530657