Unbalanced parentheses in code.

 
Hlw guys i am having trouble with unbalanced parenthesis in my code. Can anyone help me please;
#include  <Trade/Trade.mqh>


int handle;
int barsTotal;

CTrade trade;

ulong posTicket;

int OnInit(){

  handle= iMACD(_Symbol,PERIOD_CURRENT,12,26,9,PRICE_CLOSE);
  barsTotal = iBars(_Symbol,PERIOD_CURRENT);
   
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason){
   
  }
void OnTick(){


   int bars = iBars(_Symbol,PERIOD_CURRENT);
   if( bars > barsTotal){
     barsTotal = bars;
   

   double macd[];
   CopyBuffer(handle,MAIN_LINE,1,2,macd);
   
   double signal[];
   CopyBuffer(handle,SIGNAL_LINE,1,2,signal);
   
   
   
   if(macd[1] > signal[1] && macd[0] < signal[0]){
     Print(__FUNCTION__, "> BUY CROSSOVER...");
     
    if(posTicket > 0 && PositionSelectByTicket(posTicket)){
      if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL){
        if(trade.PositionClose(posTicket)){
          Print(__FUNCTION__," Sell Trade",posTicket," was Closed..");
          posTicket = 0;
        }
      }  
    
    }else  {
    Print(__FUNCTION__,"> Pos", posTicket,"was closed..." );
     posTicket = 0;
    }
    
    if(posTicket<= 0){    
    
       double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
       
       double tp = ask + 100* _Point;
       tp = NormalizeDouble(tp,_Digits);
      
       double sl = ask - 100* _Point;
       sl = NormalizeDouble(sl,_Digits);
    
       
     if(trade.Buy(0.1,_Symbol,0,sl,tp)){
     posTicket = trade.ResultOrder();
     }
     }
   
   } else if (macd[1] < signal[1] && macd[0] > signal[0]){
     Print(__FUNCTION__,"> SELL CROSSOVER...");
   
   
   if(posTicket > 0 && PositionSelectByTicket(posTicket)){
      if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY){
        if(trade.PositionClose(posTicket)){
          Print{__FUNCTION__," Buy Trade",posTicket," was Closed..");
          posTicket = 0;
        }
      }  
    
    } else  {
    Print(__FUNCTION__,"> Pos", posTicket,"was closed..." );
     posTicket = 0;
    }
    
    
    if(posTicket <= 0){
    
      double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
       
       double tp = bid - 100* _Point;
       tp = NormalizeDouble(tp,_Digits);
      
       double sl = bid + 100* _Point;
       sl = NormalizeDouble(sl,_Digits);
    
     if(trade.Sell(0.1,_Symbol,0,sl,tp)){
     posTicket = trade.ResultOrder();
     }
     }
   }
    Comment("Total");
   
   }
   }
   
   
   
   
  
   
  
 
aviyadav321:
Hlw guys i am having trouble with unbalanced parenthesis in my code. Can anyone help me please;

This line is wrong:

          Print{__FUNCTION__," Buy Trade",posTicket," was Closed..");

Should be

          Print(__FUNCTION__," Buy Trade",posTicket," was Closed..");

I think that's it...


Also switch on bracket matching if you have not done so already and compile frequently as you type



 
aviyadav321: i am having trouble with unbalanced parenthesis in my code. Can anyone help me please;
    Comment("Total");
   
   } // else if (macd[1] < signal[1] && macd[0] > signal[0]){
   } // if( bars > barsTotal){
// Missing OnTick.
 

William Roeder #:

// Missing OnTick.


Actually that was the first thing I tried - did not seem to work.

I fixed the incorrect print statement and it compiled instantly

Reason: