MQL4 Reference Trade Functions OrdersHistoryTotal

MQL4 Help as One File:

OrdersHistoryTotal

Returns the number of closed orders in the account history loaded into the terminal.

int  OrdersHistoryTotal();

Returned value

The number of closed orders in the account history loaded into the terminal. The history list size depends on the current settings of the "Account history" tab of the terminal.

Example:

  // retrieving info from trade history
  int i,hstTotal=OrdersHistoryTotal();
  for(i=0;i<hstTotal;i++)
    {
     //---- check selection result
     if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
       {
        Print("Access to history failed with error (",GetLastError(),")");
        break;
       }
     // some work with order
    }