Place 2 order then stop

 

Hello everyone 

My EA would open 1 instant position & 1 Pending orders.

I would like the EA to check if there any orders, if there are none proceed to open those 2 position (Per symbol).

What is the best method of implementation here?

Currently this EA keep opening position non stop.

void OnTick()    

if (Hour()==00&&Minute()>01)
      {  
                
                if (Pivot>C)
                {
                         // send a sell order
                         int sellticket = OrderSend
                         (
                           Symbol(),                 
                           OP_SELLLIMIT,        
                           lots,                        
                           Pivot,            
                           3,                               
                           StopLossLimit(),             
                           TakeProfitLimit(),
                           NULL,                          
                           0,                             
                           0,                               
                           Green                        
                          );  
                          
                          int sellnowticket = OrderSend
                         (
                           Symbol(),                 
                           OP_SELLLIMIT,         
                           lots,                        
                           Pivot,            
                           3,                               
                           StopLossLimit(),             
                           TakeProfitLimit(), 
                           NULL,                          
                           0,                               
                           0,                                
                           Green                        
                          );
                          
                          
                            
                  }
                     
                  else
                  {
                  
                  // send a sell order
                         int buyticket = OrderSend
                         (
                           Symbol(),                 
                           OP_BUYLIMIT,         
                           lots,                         
                           Pivot,            
                           3,                               
                           StopLossLimit(),             
                           TakeProfitLimit(), 
                           NULL,                          
                           0,                               
                           0,                                
                           Green                        
                          );
                          
                          int buynowticket = OrderSend
                         (
                           Symbol(),                 
                           OP_BUY,               
                           lots,                        
                           Bid,              
                           3,                                
                           StopLossLimit(),             
                           TakeProfitLimit(), 
                           NULL,                          
                           0,                               
                           0,                               
                           Green                       
                          );
                          
                          
                  
                  }  

         }
 
gluonsmuons: What is the best method of implementation here? Currently this EA keep opening position non stop.

Of course, it keeps opening. Where do you test for open orders?