How do i close some of the multiple open order?

 
int Pos_Order_Ticket[1];        
   int TotalOrders = OrdersTotal();
   if(ArrayResize(Pos_Order_Ticket, TotalOrders) == TotalOrders)
   {
      for(i = TotalOrders - 1; i >= 0; i--)
      {
         if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
         {
            Pos_Order_Ticket[i] = OrderTicket();
         }
         else
         {
            Pos_Order_Ticket[i] = EMPTY;
         }
         if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
         Comment ("Ticket: ", 
         Pos_Order_Ticket[i]);
      }
   }

for example.. if the current order >= 10..i want to close the earliest 5 open order ? 

how do i store the Index align with the ticket number..and use that to close the order?