//+------------------------------------------------------------------+
//|                                         CloseStopLimitOrders.mq4 |
//|                               Copyright © 2010, Vladimir Hlystov |
//|                                                cmillion@narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Vladimir Hlystov"
#property link      "http://cmillion.narod.ru"
#property show_confirm
//+------------------------------------------------------------------+
int start()
  {
   int err;
   for (int j = OrdersTotal(); j >=0 ; j--)
   {
      Print("Запуск скрипта удаляющего все отложенные ордера ",TimeToStr(TimeCurrent(),TIME_MINUTES)," попытка ",err);
      if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
      {
         if(OrderType()>1)
         {
            while(true)
            {
               if (OrderDelete(OrderTicket())) break;
               else
               {
                  err++;
                  if (err>10) break;
                  Sleep(1000);
                  RefreshRates();
               }
            }
         }
      }
      else Print( "Error when order select ", GetLastError());
   }
   return(0);
  }
//+------------------------------------------------------------------+