how to solove the ticket repeat open problom

 
  if(openmode1==true)
  {
  if(((H1usd1>H1eur1)&&(H1usd1>H1gbp1))&&((H1usd0>H1eur0)&&(H1usd0>H1gbp0)))
   {//doAlert("多1");
      if((usd2<eur2)||(usd2<gbp2)){//doAlert("多11");
         if((usd1>eur1)&&(usd1>gbp1))
{if(!haveopenticket())    //check have ticket
{
           doAlert("eurusd down");
             if(!onecurrencesellstat())  orderenter(onecurrence,false,getlots(),0);     //openticket
             if(!seccurrencesellstat())  orderenter(seccurrence,false,getlots(),0);
              Sleep(50000);
              return(0);
         }
           
         } 
      }
   }
 bool haveopenticket()
   {
      bool buysellstat=false;
      if(OrdersTotal()>0)
         {
            for(int i=0;i<OrdersTotal();i++)
               {
                  if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
                     {
                         if(OrderMagicNumber()==magic)
                           {
                                buysellstat=true;
                                break;
                           }
                     }
               }
          }  
      return(buysellstat);                       
   }     
I have check ticket open condition ,but the tick come very fast ,the order have be repeat run,the order open four ticket for me,what can i to do solove 
the problom

 
cctvzdj: have check ticket open condition ,but the tick come very fast ,the order have be repeat run,the order open four ticket for me,what can i to do solove
if(!haveopenticket())    //check have ticket
Obviously your function is broken.
Reason: