//+------------------------------------------------------------------+
//|                                    delete all pending orders.mq4 |
//|                                                          ......h |
//|                                                    hayseedfx.com |
//+------------------------------------------------------------------+
#property copyright "......h"
#property link      "hayseedfx.com"

#property indicator_chart_window
extern int ordertype = 1;

int precheck;
int init()
  {
   precheck = Count(ordertype);

   return(0);
  }  

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+

int start()
  {
  
   RefreshRates();
   Count(ordertype);
   
//----   
   if(Count(ordertype) == 0) {Alert("There are no orders of that type");}  // or do something else
//----
   
   RefreshRates();
   Count(ordertype);
   
   Comment(Count(ordertype));
   
   return(0);
  }
//+------------------------------------------------------------------+

int Count(int type)
{
  int cnt = 0;
 
  int total = OrdersTotal();
  for(int i=0; i<total; i++)
     {
    if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
   
    if(OrderSymbol()  != Symbol())                  continue;
    if(OrderType()    != type)                      continue;
     cnt++;
  }
 
  return (cnt);
}

