mq4_How to use two-dimentional array for order tickt

 

HI, please give me some advice.

Below is the code sample to select the 2nd oldest opened order.

I want to do similar things.

I want to put ticket number and order profit in 2-dimentinal array.

For example,

[Ticket# , Profit]

#12, $12, #14, -$1,  .......

I see that I can use for next roop code to select all orders, but how can I add OrderTicket() and OrderProfit() into 2-dimentioan array?

What I want is after putting these into Array, then I want to compaire the profit each other and select the order by ticket# and close it.

So it would be nice to put all into Array so that I can use easily.


int secondorder(int magic)
   {
   int mypool[];
   int secondticket, count;
   for(int i=0;i<=OrdersTotal()-1;i++)
      {
      OrderSelect(i,SELECT_BY_POS);
      if (OrderSymbol()!=Symbol() || OrderType()>1 || OrderMagicNumber()!=magic)
         {
         continue;
         }
      count++;
      ArrayResize(mypool,count);
      mypool[count-1]=OrderTicket();
      }
   if (count>1)
      {
      ArraySort(mypool,count,0,MODE_ASCEND);
      secondticket=mypool[1];
      }
   return (secondticket);
   }
 
Cromo: I see that I can use for next roop code to select all orders, but how can I add OrderTicket() and OrderProfit() into 2-dimentioan array?\
Sort orders based on OrderOpenTime MQL4 programming forum
 
If I sort by OrderOpenTime , is it possible to pick up the most profit order and the most less profit order and 3nd profit order etc...?
 
Cromo: If I sort by OrderOpenTime , is it possible to pick up the most profit order and the most less profit order and 3nd profit order etc...?

Sort by profit instead. When in doubt, THINK!

Reason: