What is the order of trades in 'trade pool' and 'history pool' ?

 

Hi does anyone know when we select the trades by position eg 0, 1, 2 in the 'trade pool' and 'history pool'.

0 mean the trade at the top of the list. But is this affected by how the rows are sorted when we manually clicked the column headers ?

Would it affect how the EA select trades, if we click on the column headers manually when the EA is processing the order list ?

Thanks,

Hip

 
I have just tested with this ea, and: not affects. But the 'history pool' depends on what history interval has been selected manually.
Files:
 
hip280:

Hi does anyone know when we select the trades by position eg 0, 1, 2 in the 'trade pool' and 'history pool'.

0 mean the trade at the top of the list. But is this affected by how the rows are sorted when we manually clicked the column headers ?

Would it affect how the EA select trades, if we click on the column headers manually when the EA is processing the order list ?

  1. Zero mean the earliest one placed on the list. For the trade pool it would be first placed trade.
  2. For the history pool see Could EA Really Live By Order_History Alone? - MQL4 forum #2
  3. Clicking the column headers are irrelevant.
 
hip280:

Hi does anyone know when we select the trades by position eg 0, 1, 2 in the 'trade pool' and 'history pool'.

0 mean the trade at the top of the list. But is this affected by how the rows are sorted when we manually clicked the column headers ?

Would it affect how the EA select trades, if we click on the column headers manually when the EA is processing the order list ?

Thanks,

Hip

When back testing this seems to work as you might expect with orders entering the list sequentially. When done in live accounts you are better off considering the ordering as random and sorting it yourself. It is trivial to print out the order history in the sequence it is provided in, but understanding what that sequence was derived from seemed non-trivial to me, so I just sorted the series myself.
 

By the way, the OrdersHistory also contains balance transfers, identifiable as OrderSymbol()==""

If you have 5 or 6 orders in your history you may be lulled in a false sense of security and think you have the pattern figured out.

I just checked it this evening to make sure and of 150 trades in the history there are not just a few out of date order, but lots. The first errors didn't appear until 30 items into the list.

 
To expand upon this, the manner in which you sort the columns Live does not affect the order-select pool. OrdersTotal()-1 will be in the sequence the were opened. Similar to expecting the next Ticket# to be greater then the previous. If this was not the case, I'd had allot of problems live because I'm always sorting the active trade and history columns by Symbol, LotSize etc all the time.
 
erzo:
I have just tested with this ea, and: not affects. But the 'history pool' depends on what history interval has been selected manually.

I have tested with your EA, and I found that in both 'trade pool' and 'history pool', the list is sorted by time the trade is opened.

i.e the same sort order when clicking the opening 'time' column header.

Thus, for the 'trade pool', 0 means the trade with the earliest opening time, while OrdersTotal-1 means the trade with the most recent opening time.

And for the 'history pool', 0 means the trade with the earliest opening time, while OrdersHistoryTotal-1 means the trade with the most recent opening time. (It does not use closing time of the trade).

Did you have the same conclusion ?

 
hip280:

I have tested with your EA, and I found that in both 'trade pool' and 'history pool', the list is sorted by time the trade is opened.

i.e the same sort order when clicking the opening 'time' column header.

Thus, for the 'trade pool', 0 means the trade with the earliest opening time, while OrdersTotal-1 means the trade with the most recent opening time.

And for the 'history pool', 0 means the trade with the earliest opening time, while OrdersHistoryTotal-1 means the trade with the most recent opening time. (It does not use closing time of the trade).

Did you have the same conclusion ?

There is no explicit documentation of the sorting order of this list, so better considering it as random sorted, as Dabbler suggested. It can depend on brokers also.

Perhaps there is a more experienced programmer here, who can point the documentation of this. But, if not, when the sequence of list is critical, you should build a custom array of it, then sort yourself.

 
hip280:

Hi does anyone know when we select the trades by position eg 0, 1, 2 in the 'trade pool' and 'history pool'.

0 mean the trade at the top of the list. But is this affected by how the rows are sorted when we manually clicked the column headers ?

Would it affect how the EA select trades, if we click on the column headers manually when the EA is processing the order list ?

Thanks,

Hip

Would it affect ... ? Yes if you using Intel 4004 processor. Today processors is so fast, it will finish the job before you even start it.

You can always filter them out like ...

int Filter = The_Limit  ; // put time or ticket number here

for (pos = 0; pos <= OrdersHistoryTotal(); pos ++)
      {
      if (OrderSelect (pos, SELECT_BY_POS) == true)
        {
        if (OrderOpenTime () <= Filter) continue ;     // We're not looking for the lowest time nor ticket ...
        // if (OrderCloseTime () <= Filter) continue ; // ... because the biggest time or the biggest ticket number ...
        // if (OrderTicket ()    <= Filter) continue ; // ... is the newest order.
           else
           {
           // do the job, then ...
           Filter = OrderOpenTime(); // 
           Filter = OrderCloseTime();
           Filter = OrderTicket ();
           }
        }
     }

Ticket number is incremented, so the biggest ticket number is the newest order.

<code is not compiled>

Have fun :)

Reason: