Sorting of OrdersHistory() in MQL4 >build 509 was changed! - page 2

 
Kajos2250:


So, for 7 sec your EA can not do nothing else and does not know other data...and this repeats in every tick... It is not proper for my startegy... I have to find some other solution...

Just you know the order selection takes more time than get information from the selected order (eg. OrderTicket(), OrderOpenTime()..)


Just use obsolute order by. instruct your ea to sort it like the way you wanted it to sort. its that simple. no biggie here. update your code. not mt4 have to follow your code.
 
Kajos2250:


So, for 7 sec your EA can not do nothing else and does not know other data...and this repeats in every tick... It is not proper for my startegy... I have to find some other solution...

Just you know the order selection takes more time than get information from the selected order (eg. OrderTicket(), OrderOpenTime()..)


No, not necessary every tick

If I needed to do this, I would store and order the closed orders in an array

Then every tick, I would check if OrdersHistoryTotal had changed, find the latest closed order(s), resize the array and insert the newly closed trade

 
qjol:
just for the fun of it i just dealt with 1741 orders in the history, it took exactly 7 seconds

Doesn't 7 seconds sound ridiculously slow though ? To loop through an array of 1700 indexes should take a microsecond. When you consider loading an indicator on a small time frame chart can easily loop through tens of thousands of indexes of several of the series arrays, doing calculations on them, filling the buffer arrays at the same time yet it does that in a blink of an eye I have always wondered what is up with the orders history array for being so slow to access.

Would you try something else on that same history ? Use OrderSelect(ticket,SELECT_BY_TICKET) to call one of the orders that is in the history by its ticket number to see how long that takes ?

I have been avoiding calling Mode_History in my EA's because it takes so long when there are a lot of orders, instead I manage them internally and call information using SELECT_BY_TICKET because I assumed it would be faster but, I never actually tested if it was faster.

 
SDC:

Doesn't 7 seconds sound ridiculously slow though ? To loop through an array of 1700 indexes should take a microsecond. When you consider loading an indicator on a small time frame chart can easily loop through tens of thousands of indexes of several of the series arrays, doing calculations on them, filling the buffer arrays at the same time yet it does that in a blink of an eye I have always wondered what is up with the orders history array for being so slow to access.

ask MetaQuotes

Would you try something else on that same history ? Use OrderSelect(ticket,SELECT_BY_TICKET) to call one of the orders that is in the history by its ticket number to see how long that takes ?

how i supposed to know the ticket no. ?

I have been avoiding calling Mode_History in my EA's because it takes so long when there are a lot of orders, instead I manage them internally and call information using SELECT_BY_TICKET because I assumed it would be faster but, I never actually tested if it was faster.

ho, i did ;-)

 
SDC:

Doesn't 7 seconds sound ridiculously slow though ? To loop through an array of 1700 indexes should take a microsecond. When you consider loading an indicator on a small time frame chart can easily loop through tens of thousands of indexes of several of the series arrays, doing calculations on them, filling the buffer arrays at the same time yet it does that in a blink of an eye I have always wondered what is up with the orders history array for being so slow to access.

Would you try something else on that same history ? Use OrderSelect(ticket,SELECT_BY_TICKET) to call one of the orders that is in the history by its ticket number to see how long that takes ?

I have been avoiding calling Mode_History in my EA's because it takes so long when there are a lot of orders, instead I manage them internally and call information using SELECT_BY_TICKET because I assumed it would be faster but, I never actually tested if it was faster.


Possibly not the same because I often use GVs to store ticket numbers

When I select the order by ticket, check orderclosetime!=0 and open a new order, everything is usually completed within one or 2 tenths of a second

 

qjol:

how i supposed to know the ticket no. ?

It would be in the terminal history no ?

So when you tested SELECT_BY_TICKET was it faster ?

 
I guess I'll just have to test it myself. Except when I do it, I will share the results.