Unbalanced parenthesis help!

 

Hi, I get an error regarding an unbalanced parenthesis. I've even numbered them, and they seem to match. Perhaps I am missign something. Help would be appreciated. Thanks


//+------------------------------------------------------------------+
//|                                         AutoTrader for Lines.mq4 |
//|                                                          Gulzaar |
//|                          http://www.forexmastermindblueprint.com |
//+------------------------------------------------------------------+
#property copyright "Gulzaar"
#property link      "http://www.forexmastermindblueprint.com"


extern int NumberOfLines = 5;
extern int StopLoss = 50;
extern int TakeProfit = 50;
extern double NumberOfLots = 0.1;
extern string LineName = "Line";
extern int Accuracy = 10;
extern int MagicNumber = 78652;
int Ticket;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {// :1
//----
   if(Digits == 5) {//:2
         StopLoss = StopLoss*50;
         TakeProfit = TakeProfit*50;
                     }//:2
      Accuracy = Accuracy * Point;
//----
   return(0);
  }// :1
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {//:3
//----
   
//----
   return(0);
  }//:3
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {//:4
//----
   for(int i = 0; i <= NumberOfLines; i++)
         {//:5
   
      string NewLineName = StringConcatenate(LineName,i);
      
      double SRlevel = ObjectGet(NewLineName,OBJPROP_PRICE1);
      
      if((MathAbs(SRlevel - Close[0]) <= Accuracy){// :6 
               if(Close[1] < SRlevel && Close[2] < SRlevel) bool BuyTrade = true;
               if(Close[1] > SRlevel && Close[2] > SRlevel) bool SellTrade = true;
                        }// :6
                        
                       
      if(BuyTrade) { //:7
                     Ticket = OrderSend(Symbol(),OP_BUY,NumberOfLots,Ask,MarketInfo(Symbol(),MODE_SPREAD),0,0,0,MagicNumber,3);
                     OrderModify(Ticket,OrderOpenPrice(),Ask-StopLoss,Ask+TakeProfit,0, MediumSeaGreen);
                     }  //:7 
      
      if(SellTrade) { //:8
                       Ticket = OrderSend(Symbol(),OP_SELL,NumberOfLots,Bid,MarketInfo(Symbol(),MODE_SPREAD),0,0,0,MagicNumber,3);
                     OrderModify(Ticket,OrderOpenPrice(),Bid+StopLoss,Bid-TakeProfit,0, MediumSeaGreen);
                     }  //:8
      
   }//:5
//----
   return(0);
  }//:4
//+------------------------------------------------------------------+
 
gulzaar:

Hi, I get an error regarding an unbalanced parenthesis. I've even numbered them, and they seem to match. Perhaps I am missign something. Help would be appreciated. Thanks



if((MathAbs(SRlevel - Close[0]) <= Accuracy){// :6 
One too many ( right after "if "
 
Dingetje:

One too many ( right after "if "

Thanks! Problem solved:)
 

I have a problem with unbalanced parenthesis too.

//+------------------------------------------------------------------+

//|                                                  MACrossover.mq4 |

//|                        Copyright 2019, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link      "https://www.metaquotes.net"


extern int TakeProfit=50;

extern int StopLoss=25;

extern int FastMA=5;

extern int FastMaShift=0;

extern int FastMaMethod=0;

extern int FastMaAppliedTo=0;

extern int SlowMA=21;

extern int SlowMaShift=0;

extern int SlowMaMethod=0;

extern int SlowMaAppliedTo=0;

extern double LotSize=0.01;

extern int MagicNumber =2121;

double pips;

//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int init()

 {

//----

      double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE);

      if  (ticksize == 0.00001 || ticksize==0.001)

      pips = ticksize*10;

      else pips=ticksize;

  

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

int deinit()

  {

//----


//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Expert start function                                             |

//+------------------------------------------------------------------+

int start()

  {

//----

  double PreviousFast = iMA(NULL,0,FastMA,FastMaShift,FastMaMethod,FastMaAppliedTo,2);

  double CurrentFast = iMA(NULL,0,FastMA,FastMaShift,FastMaMethod,FastMaAppliedTo,1);

  double PreviousSlow = iMA(NULL,0,SlowMA,SlowMaShift,SlowMaMethod,SlowMaAppliedTo,2);

  double CurrentSlow = iMA(NULL,0,SlowMA,SlowMaShift,SlowMaMethod,SlowMaAppliedTo,1);

  if (PreviousFast<PreviousSlow && CurrentFast>CurrentSlow)

     if(OrdersTotal()==0)

        OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,Ask-(StopLoss*pips),Ask+(TakeProfit*pips),NULL,MagicNumber,0,Green);

  if (PreviousFast>PreviousSlow && CurrentFast<CurrentSlow)

     if(OrdersTotal()==0)

        OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+(StopLoss*pips),Bid-(TakeProfit*pips),NULL,MagicNumber,0,Red);

 


//----

   return(0);

  }

//+------------------------------------------------------------------+


Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
Ask questions on technical analysis, discuss trading systems and improve your MQL5 programming skills to develop your own trading strategies. Communicate and share your experience with traders from anywhere in the world, answer questions and help beginners — MQL5.community is developing along with you. How to loop x Up bar only and vice versa...
 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. You can't define a function inside another function.
    int init()
     {
          double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE);
    ⋮
          else pips=ticksize;
        
    int deinit()
     {

  3. You should stop using the old event handlers and IndicatorCounted and start using the new ones.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference
              How to do your lookbacks correctly.

Reason: