//+------------------------------------------------------------------+
//|                                            close-all-orders.mq4  |
//|                                  Copyright © 2005, Matias Romeo. |
//|                                       Custom Metatrader Systems. |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2005, Matias Romeo."
#property link      "mailto:matiasDOTromeoATgmail.com"

int start()
{
  int total = OrdersTotal();
  
  Print ("total is ", total);
  
  for(int i=total-1;i>=0;i--)
  {
    OrderSelect(i, SELECT_BY_POS);
    int type = OrderType();

    bool result = false;
    
    if(OrderSelect(i, SELECT_BY_POS) == true && OrderSymbol() == ChartSymbol())
      Print("symbol of order #", i+1, "-", OrderTicket(), " is ", OrderSymbol()," & chart symbol is ", ChartSymbol(), " - ", OrderProfit(), " - ", OrderType(), " -");
    else    Print("OrderSelect failed error code is ",GetLastError(), " - ", OrderSymbol(), " - ", ChartSymbol());
    }  
  return(0);
}

