Unexpected and Unbalanced Parentheses

 

Hello MQL5 Community,

I'd appreciate it if you could help me with the following errors in my code.

The first is at the beginning of my "int OnInit()" code, and the second is at the end: "return(point);"

I had previously made some minor changes to the code in order to resolve other errors. I'm having trouble figuring out the two remaining.

I may be missing a "Parentheses" somewhere and am having difficulty locating it.

Your assistance is greatly appreciated.

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
// Detect 3/5 digit brokers for Point and Slippage

   if(Point == 0.00001)
     { vPoint = 0.0001; vSlippage = Slippage *10;}
   else
     {
      if(Point == 0.001)
        { vPoint = 0.01; vSlippage = Slippage *10;}
      else
         vPoint = Point;
      vSlippage = Slippage;

      if(TrailingStop && TrailingStart <= 0)
        {
         Alert("Parameters incorrect");
         return (INIT_PARAMETERS_INCORRECT);
        }
      myPoint     = GetPipPoint(Symbol());
     }
     
void OrdersAccounting ()
{                                                                    
Display EAinfo(); // Returns total number of positions already open

     {
      Print("Free margin for 1 lot=",MarketInfo(Symbol(), MODE_MARGINREQUIRED));
      Print("Freezing Distance[pts]=",MarketInfo(Symbol(), MODE_FREEZELEVEL));
      Print("Min Allowed Distance[pts]=",MarketInfo(Symbol(), MODE_STOPLEVEL));
      Print("MODE_LOTSIZE = ", MarketInfo(Symbol(), MODE_LOTSIZE));
      Print("MODE_MINLOT = ", MarketInfo(Symbol(), MODE_MINLOT));
      Print("MODE_LOTSTEP = ", MarketInfo(Symbol(), MODE_LOTSTEP));
      Print("MODE_MAXLOT = ", MarketInfo(Symbol(), MODE_MAXLOT));
     }
//---
   return(INIT_SUCCEEDED);
  }
  
// Global Variables
double vPoint;
int vSlippage;
double   myPoint = Point()*10;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(!(bool)TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
      return;

   static int  maCross  =  0;
   static int  cciCross =  0;
   static int  ticket = 0;
   string comment;
   static bool NewBar = true;
   setTrailingStop(Magic);


   bool  newBar   =  NewBar();
   if(newBar)
     {
      double   cci1     =  iCCI(Symbol(), Period(), CCIPeriod, CCIPrice, 1);
      double   cci2     =  iCCI(Symbol(), Period(), CCIPeriod, CCIPrice, 2);

      if(cci1<100 && cci2>=100)
         cciCross =  1;
      if(cci1>-100 && cci2<=-100)
         cciCross =  -1;
         
void GetIndicatorValue (){

      double   fastMa1  =  iMA(Symbol(),0, MA_Period, MA_Shift, MA_Method, MA_Price, 1);
      double   fastMa2  =  iMA(Symbol(),0, MA_Period, MA_Shift, MA_Method, MA_Price, 2);
      double   slowMa1  =  iMA(Symbol(),0, SlowMAPeriods, MA_Shift, SlowMAMethod, SlowMAPrice, 1);
      double   slowMa2  =  iMA(Symbol(),0, SlowMAPeriods, MA_Shift, SlowMAMethod, SlowMAPrice, 2);

      
   if(Hour() == StartHour)
     {
      comment = GetDateAndTime();
      if(NewBar == true)
        {
         NewBar = false;
         if(iVolume(NULL,0,0)>1)


            //FindTicket makes sure that the EA will pick up its orders
            //even if it is relaunched
            ticket = FindTicket(Magic);

         bool res;
         res = OrderSelect(ticket, SELECT_BY_POS,MODE_TRADES);
         if(res == true)
           {
            if(OrderCloseTime() == 0)

              {
               bool res2;
               res2 = OrderClose(ticket, Lots, OrderClosePrice(), 10);

               if(res2 == false)
                 {
                  Alert("Error Closing Order #", ticket);
                 }
              }
           }

      if(fastMa1>slowMa1 && fastMa2<=slowMa2)
        {
         maCross  =  -1;
         ticket = (OP_SELL);
        }

      if(fastMa1<slowMa1 && fastMa2>=slowMa2)
        {
         maCross  =  1;
         ticket = (OP_BUY);
        }
      if(maCross!=0 && maCross==cciCross)
        {
         if(OpenTrade(maCross)>0)
           {
            maCross  =  0;
            cciCross =  0;
           }
        }
     }
  }

//+------------------------------------------------------------------+
//|                     Auxiliary Functions                          |
//+------------------------------------------------------------------+
int FindTicket(int M)
  {
   int ret = 0;
   int total = OrdersTotal();
   for(int i = 0 ; i < total ; i++)
     {
      bool res;
      res = OrderSelect(i, SELECT_BY_POS,MODE_TRADES);
      if(res == true)
        {
         if(OrderMagicNumber() == M)
           {
            ret = OrderTicket();
            break;
           }
        }
     }

   return(ret);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int   OpenTrade(int maCross)
  {
           if(Open[0] < Open[StartHour] - MinPipLimit*MyPoint) //v3.0
         {
            //check ma
            if(Close[1] > maCross
            {
               //here we are assuming that the TakeProfit and StopLoss are entered in Pips
               ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, vSlippage, Bid-StopLoss*vPoint, Bid+TakeProfit*vPoint, "Set by Process Expert Advisor", Magic,0,Blue);
               if(ticket < 0)
                              {
                  comment = comment + " " + "Error Sending BUY Order";
               }
               else
               {
                  comment = comment + " " + "BUY Order Executed Succesfuly";
               }               
            }
            else
            {
                  comment = comment + " " + "Reason Order Not Opened: MinPipLimit Filter Not Passed";
            }
         }
         else if(Open[0] > Open[StartHour] + MinPipLimit*MyPoint) //v3.0
         {
            //check ma
            if(Close[1] < maCross
            {
                  ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, vSlippage, Ask+StopLoss*vPoint, Ask-TakeProfit*vPoint, "Set by Process Expert Advisor", Magic,0,Blue);
                  if(ticket < 0)
                              {
                  comment = comment + " " + "Error Sending SELL Order";
               }
               else
               {
                  comment = comment + " " + "SELL Order Executed Succesfuly";
               }                  
            }
         }
         else
         {
            comment = comment + " " + "Reason Order Not Opened: MinPipLimit Filter Not Passed";
         }
         
         Comment(comment);
         Print(comment);
      }

   }
   else
   {
      NewBar = true;

  }
  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool  NewBar()
  {
   static datetime   current  =  0;
   datetime          now      =  iTime(Symbol(), Period(), 0);
   if(now == current)
      return(false);
   current  =  now;
   return(true);
  }

//+------------------------------------------------------------------+
//|                        Trailing Stop                             |
//+------------------------------------------------------------------+
void setTrailingStop(int magicNumber=0)
  {
   if(TrailingStop==false)
      return;

   int      tOrder = 0;
   string   pair = "";
   double   sl = 0.0, tp = 0.0;

   pair = Symbol();

   tOrder = OrdersTotal();
   for(int i=tOrder-1; i>=0; i--)
     {
      bool hrsSelect = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderMagicNumber() == magicNumber && StringFind(OrderSymbol(), pair, 0) == 0)
        {
         if(OrderType() == OP_BUY)
           {
            if((Bid - (TrailingStart * myPoint)) >= OrderOpenPrice()
               && (Bid - ((TrailingStart+TrailingStep) * myPoint) >= OrderStopLoss())
              )
              {
               sl = NormalizeDouble(Bid - (TrailingStart * myPoint), Digits());
               if(!OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0, clrBlue))
                 {
                  Print("#", OrderTicket(), " get minimum stop level");
                 }
              }
           }

         if(OrderType() == OP_SELL)
           {
            if((Ask + (TrailingStart * myPoint)) <= OrderOpenPrice()
               && ((Ask + ((TrailingStart+TrailingStep) * myPoint) <= OrderStopLoss()) || OrderStopLoss() == 0.0)
              )
              {
               sl = NormalizeDouble(Ask + (TrailingStart * myPoint), Digits());
               if(!OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0, clrBlue))
                 {
                  Print("#", OrderTicket(), " get minimum stop level");
                 }
              }
           }
        } //end if magicNumber
     }//end for
  }

//+------------------------------------------------------------------+
//|                       Broker Pip Points                                           |
//+------------------------------------------------------------------+

// Fungsi GetPipPoint
double GetPipPoint(string pair)
  {
   double point= 0.0;
   int digits = (int) MarketInfo(pair, MODE_DIGITS);
   if(digits == 2 || digits== 3)
      point= 0.01;
   else
      if(digits== 4 || digits== 5)
         point= 0.0001;
   return(point);
  }
//+------------------------------------------------------------------+
 
OTMT Howard:Hello MQL5 Community, I'd appreciate it if you could help me with the following errors in my code. The first is at the beginning of my "int OnInit()" code, and the second is at the end: "return(point);"

I had previously made some minor changes to the code in order to resolve other errors. I'm having trouble figuring out the two remaining. I may be missing a "Parentheses" somewhere and am having difficulty locating it. Your assistance is greatly appreciated.

You should practice to identify these kind of errors yourself. The second message gives you the clue by identifying the OnInit function. Then use the built-in highlighting of brackets and braces to identify the corresponding one.

int OnInit()
  {
//---
// Detect 3/5 digit brokers for Point and Slippage

   if(Point == 0.00001)
     { vPoint = 0.0001; vSlippage = Slippage *10;}
   else
     {
      if(Point == 0.001)
        { vPoint = 0.01; vSlippage = Slippage *10;}
      else
         vPoint = Point;
      vSlippage = Slippage;

      if(TrailingStop && TrailingStart <= 0)
        {
         Alert("Parameters incorrect");
         return (INIT_PARAMETERS_INCORRECT);
        }
      myPoint     = GetPipPoint(Symbol());
     }
  } // <--- missing

void OrdersAccounting ()
 
Fernando Carreiro #:

You should practice to identify these kind of errors yourself. The second message gives you the clue by identifying the OnInit function. Then use the built-in highlighting of brackets and braces to identify the corresponding one.

Hei fernando,

Thank you for the assist. I have enabled these items.


After inserting the missing parentheses. I got a list of 8 more errors of which I am really lost in resolving at this point.

Reason: