Ordersend makes too many orders at once !

 

 Ordersend is keep opening way to many orders at once (like 100-200 orders ), How can i just make one order per signal ?! 


   MqlTradeRequest request   = {0}; // nulling MqlTradeRequest structure
   MqlTradeResult result     = {0};



void OnTick()
  {
  

// My logic 
.......



  if ( signal=="sell" && PositionsTotal() < 1 && OrdersTotal() < 1 ) 


//--- parameters of request
   request.action   =TRADE_ACTION_PENDING;                     // type of trade operation
   request.symbol   =_Symbol;                              // symbol
   request.volume   =2;                                  
   request.type     =ORDER_TYPE_SELL_STOP; 
   request.sl      = NormalizeDouble(pricedata[1].high + sll * _Point,_Digits);                                    
   request.tp      = NormalizeDouble(pricedata[1].low - tpp * _Point,_Digits);                      
   request.price    =NormalizeDouble(pricedata[1].low - 5 * _Point,_Digits); // price for opening
   request.deviation=1;                                     // allowed deviation from the price
   request.magic    =magic;      
   OrderSend(request,result);
      
      
      
      
      
    if ( signal=="buy" && PositionsTotal() < 1 && OrdersTotal() < 1 ) 

//--- parameters of request
   request.action   =TRADE_ACTION_PENDING;                  // type of trade operation
   request.symbol   =_Symbol;                              // symbol
   request.volume   =1.5;                                 
   request.type     =ORDER_TYPE_BUY_STOP; 
   request.sl      = NormalizeDouble(pricedata[1].low - sll * _Point,_Digits);                               
   request.tp      = NormalizeDouble(pricedata[1].high + tpp * _Point,_Digits);                      
   request.price    =pricedata[1].high + 5 * _Point; // price for opening
   request.deviation=1;                                     // allowed deviation from the price
   request.magic    =magic;      
   OrderSend(request,result);
      
      };
 
  if ( signal=="sell" && PositionsTotal() < 1 && OrdersTotal() < 1 ) 
      request.action   =TRADE_ACTION_PENDING;                     // type of trade operation
   request.symbol   =_Symbol;                              // symbol
   request.volume   =2;                                  
   request.type     =ORDER_TYPE_SELL_STOP; 
   request.sl      = NormalizeDouble(pricedata[1].high + sll * _Point,_Digits);                                    
   request.tp      = NormalizeDouble(pricedata[1].low - tpp * _Point,_Digits);                      
   request.price    =NormalizeDouble(pricedata[1].low - 5 * _Point,_Digits); // price for opening
   request.deviation=1;                                     // allowed deviation from the price
   request.magic    =magic;      
   OrderSend(request,result);
The if statement only effects the action. Enclose action through send with braces.
 
William Roeder:
The if statement only effects the action. Enclose action through send with braces.
Thanks , it works now
Reason: