Read last history orders

 

How a expert can to read only last 20 history orders?

Any idea?

  for(int i=0; i<OrdersHistoryTotal(); i++)
  {
  OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
  {
  Do some ....
  }
  }

Now read all history orders....

 
Count down not up.
int count=0;
    for(int iPos=OrdersHistoryTotal()-1; iPos >= 0 ; iPos--) if (
        OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY)      // Only orders w/
    &&  OrderMagicNumber() == Magic.Number                  // my magic number
    &&  OrderSymbol()      == chart.symbol                  // and my pair.
    &&  OrderType()        <= OP_SELL// Avoid cr/bal forum.mql4.com/32363#325360
    ){
        count++;
        :
        if (count == 20) break; // Only the last 20.
    }
 
WHRoeder:
Count down not up.

Thanks man, I try it :)
Reason: