Timer Delay

 
Hi. I had this EA developed and can't get hold of the developer for help.
The EA works great. All it does is opens a opposite directional position on a certain amount of pips on a specified currency.
But when I close the position created by the EA and the original 1st position is still open, the EA opens a new position immediately.
All I need is that the EA does not open a new position immediately and waits x amount of seconds and then looks if there is a 1st position open and then only opens a new position if settings allows it.

Can anyone assist me with this small technical issue?


extern int     MagicNumber = 1 ;
extern double  PipCount    = 20;
extern string  CurrencyToOpen = "GBPUSD";
extern bool    AutoClose   = false;
extern string EaComment = "Opp";

string Pair1,Pair2;
double Lot;
int ticket;
string iEaComment;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  if(Digits==3 || Digits==5){
   PipCount *=10;
  }
//--- create timer
   //EventSetTimer(60);//
      
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---    

      Pair1 = Symbol();
      Pair2 = CurrencyToOpen;

       for (int cnt = 0; cnt < OrdersTotal(); cnt++) {
         if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)){
         
           if(OrderSymbol()==Pair1 && OrderMagicNumber()==MagicNumber) {
           
           double ask = MarketInfo(Pair2,MODE_ASK);
           double bid = MarketInfo(Pair2,MODE_BID);
           
           iEaComment = (string)OrderTicket()+" "+EaComment;
           Lot       = OrderLots();
           
           if(OrderType()==OP_BUY && OrderOpenPrice()-Close[0]>=PipCount*Point){
               if(cekOpen(Pair2,iEaComment)<1) ticket = OrderSend(Pair2,OP_SELL,Lot,bid,5,0,0,iEaComment,MagicNumber,0,clrRed);
               }
           
          if(OrderType()==OP_SELL && Close[0]-OrderOpenPrice()>=PipCount*Point){
               if(cekOpen(Pair2,iEaComment)<1) ticket = OrderSend(Pair2,OP_BUY,Lot,ask,5,0,0,iEaComment,MagicNumber,0,clrBlue);
               }
           
           }
         }
       }
       
       
        string tiketnya="";
        datetime Tclose = iTime(Symbol(),0,0)-60;
        
        for (int cnt = 0; cnt < OrdersHistoryTotal(); cnt++) {
         if(OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY)){
         if(OrderSymbol()==Pair1 && OrderMagicNumber()==MagicNumber && OrderCloseTime()>=Tclose){
            tiketnya=(string)OrderTicket()+" "+EaComment;
            if(AutoClose && tiketnya!="") CloseOp(tiketnya);
         }
        }
       }
        
  
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   OnTick();
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+
int cekOpen(string pair, string komen)
{
   int tot=0;
   for (int cnt = 0; cnt < OrdersTotal(); cnt++) {
         if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)){
           if(OrderMagicNumber()==MagicNumber) {
            if(OrderSymbol()==pair && OrderComment()==komen) tot++;
           }
         }
       }
       
   return(tot);
}  

void CloseOp(string komen)
{ 
int total = OrdersTotal();  
        for(int i=total-1;i>=0;i--) {  
          if(OrderSelect(i, SELECT_BY_POS)){
            if(OrderSymbol()==Pair2 && OrderMagicNumber()==MagicNumber){
            if(OrderComment()==komen) ticket=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrBlack);
            }
         }
     }    
 }