EA executes Multiple orders

 
int start()
{
   New_Bar=false;                               
   if(New_Time!=Time[0])                        
     {
      New_Time=Time[0];                         
      New_Bar=true;     
      
   if (New_Bar==1)
  {
   double value1;
   double value2;
   
   int    ticket,total;
if(// condition //)
   

   total=OrdersTotal();
   if(total<1)
     {   
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TakeProfit*Point,Ask+TakeProfit*Point,"trial",16384,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("BUY order opened : ",OrderOpenPrice());
           }
         else
            Print("Error opening BUY order : ",GetLastError());
            return(0);
          }
       
       
   if(// condition //)
   total=OrdersTotal();
   if(total<1)
   
   {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+TakeProfit*Point,Bid-TakeProfit*Point,"trial",16384,0,Red);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("SELL order opened : ",OrderOpenPrice());
           }
         else
            Print("Error opening SELL order : ",GetLastError());
        }   
   
    
   
        return(0);
            }     
             }
             return(0);
             }
This the piece of code is responsible for sending orders. The problem when i back tested is that the EA opens multiple orders. Inspite of having an if condition to ensure that only a single order is kept open at a time. Any insights? :(
 
   int    ticket,total;
if(// condition //)
   

   total=OrdersTotal();
   if(total<1)
     {   
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TakeProfit*Point,Ask+TakeProfit*Point,"trial",16384,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("BUY order opened : ",OrderOpenPrice());
           }
         else
            Print("Error opening BUY order : ",GetLastError());
            return(0);
          }
       

only if(// condition //)

you make total=OrdersTotal();

if you want it also work on the other lines then you had to use another { } and place the code it had to work on inside

 
deVries:

only if(// condition //)

you make total=OrdersTotal();

if you want it also work on the other lines then you had to use another { } and place the code it had to work on inside


i feel so stupid...forgot to put it in a loop >.<
Reason: