Positions for loop order.

 

Hi I'd need to check the profit/loos of several positions, I'm using a for loop from PositionsTotal()-1 to 0.

How the positions have been sorted? If the position[PositionsTotal()-1] the oldest?

Here is the code:

   int      total = PositionsTotal();
   uint     trade_error_code;
   double   profit;
   double   target;
   double   tp = 200*_Point;
         
   for(int k=total-1; k>=0; k--){
      if(pos_info.SelectByIndex(k) && pos_info.Symbol()==Symbol()){
         profit = pos_info.Profit();
         target = (tp * pos_info.Volume());
         if(profit>=target){
            trade.PositionClose(pos_info.Ticket());
            trade_error_code = trade.ResultRetcode();
            if(trade_error_code==TRADE_RETCODE_DONE){
               return true;
            }
            else
            ....
            ....
         }
      }
   }  


Thanks.

Reason: