Help finding unbalanced left parenthesis

 

Could some one help me finding this error of Unbalanced left parenthesis.... i tried myself all combinations but it never solves....

and also an advise if all the cases are properly written ....

i tried to write the 4 ma crosses and cci above 100 or -100 to buy and sell ... Thanks in advance!

//magic numberの定義
#define MAGIC  4649        

//parameter //
extern double Lots = 1.0;     
extern int Slip = 10;         
extern string Comments =  ""; 

extern int FastMA1_p = 34;
extern int SlowMA1_p = 34;
extern int modeMA1 = MODE_SMA;
extern int modeMA2 = MODE_EMA;
extern int MA1Cross_Timeframe = PERIOD_M15;
extern int FastMA2_p = 68;
extern int SlowMA2_p = 68;
extern int CCI_p = 20;
extern int CCI_Buy_Point = 100;
extern int CCI_Sell_Point = -100;
extern int CCI_Timeframe = PERIOD_M30;
extern int Band_p = 6;
extern int Band_Timeframe = PERIOD_M15;



//変数の設定//
int Ticket_L = 0; 
int Ticket_S = 0; 
int Exit_L = 0;  
int Exit_S = 0;   


int start()
  {
  
  
  
    double MAFast1 = iMA(NULL, MA1Cross_Timeframe, FastMA1_p, 0, modeMA2, PRICE_CLOSE, 0);
    double MAFast2 = iMA(NULL, MA1Cross_Timeframe, FastMA1_p, 0, modeMA2, PRICE_CLOSE, 1);
    double MASlow1 = iMA(NULL, MA1Cross_Timeframe, SlowMA1_p, 0, modeMA1, PRICE_CLOSE, 0);
    double MASlow2 = iMA(NULL, MA1Cross_Timeframe, SlowMA1_p, 0, modeMA1, PRICE_CLOSE, 1);
    
    double MAFast3 = iMA(NULL, MA1Cross_Timeframe, FastMA2_p, 0, modeMA2, PRICE_CLOSE, 0);
    double MAFast4 = iMA(NULL, MA1Cross_Timeframe, FastMA2_p, 0, modeMA2, PRICE_CLOSE, 1);
    double MASlow3 = iMA(NULL, MA1Cross_Timeframe, SlowMA2_p, 0, modeMA1, PRICE_CLOSE, 0);
    double MASlow4 = iMA(NULL, MA1Cross_Timeframe, SlowMA2_p, 0, modeMA1, PRICE_CLOSE, 1);
     
     
    double cci1 = iCCI(NULL, CCI_Timeframe, CCI_p, PRICE_CLOSE, 0);
    double cci2 = iCCI(NULL, CCI_Timeframe, CCI_p, PRICE_CLOSE, 1);
    double cci3 = iCCI(NULL, CCI_Timeframe, CCI_p, PRICE_CLOSE, 2);
    
   double bands_upper1 = iBands(NULL, Band_Timeframe, Band_p,1, 0, PRICE_CLOSE, MODE_UPPER, 1);
   double bands_upper2 = iBands(NULL, Band_Timeframe, Band_p,1, 0, PRICE_CLOSE, MODE_UPPER, 2);
   double bands_lower1 = iBands(NULL, Band_Timeframe, Band_p,1, 0, PRICE_CLOSE, MODE_LOWER, 1);
   double bands_lower2 = iBands(NULL, Band_Timeframe, Band_p,1, 0, PRICE_CLOSE, MODE_LOWER, 2);
    
     
   //Buy exit
   if(   Close[2]>= bands_upper2 && Close[0] <bands_upper1
       && ( Ticket_L != 0 && Ticket_L != -1 ))
    {     
      Exit_L = OrderClose(Ticket_L,Lots,Bid,Slip,Red);
      if( Exit_L ==1 ) {Ticket_L = 0;}
    }    
    
   //Sell exit 
   if(    Close[2] <= bands_lower2 && Close[0] > bands_lower1
       && ( Ticket_S != 0 && Ticket_S != -1 ))
    {     
      Exit_S = OrderClose(Ticket_S,Lots,Ask,Slip,Blue);
      if( Exit_S ==1 ) {Ticket_S = 0;} 
    }   
    
   //  Buy entry
   if(    ( MAFast1 > MASlow1 && MAFast4 <= MASlow4 && MAFast3 > MASlow3 && cci3 < CCI_Buy_Point && cci2 <= CCI_Buy_Point && cci1 > CCI_Buy_Point )
    
    else if  (MAFast1 > MASlow1 && MAFast4 <= MASlow4 && MAFast3 > MASlow3 && cci1 > CCI_Buy_Point )
   
    else if  (  MAFast2 <= MASlow2 && MAFast1 > MASlow1 && MAFast3 > MASlow3 && cci1 > CCI_Buy_Point )
   
    else  (MAFast1 > MASlow1 && MAFast3 > MASlow3 && cci3 < CCI_Buy_Point && cci2 <= CCI_Buy_Point && cci1 > CCI_Buy_Point )
   
       && ( Ticket_L == 0 || Ticket_L == -1 ) 
       && ( Ticket_S == 0 || Ticket_S == -1 ))
    {  
      Ticket_L = (OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,0,0,Comments,MAGIC,0,Red);
    }
    
   // Sell entry 
   if(  (MAFast1 < MASlow1 && MAFast4 >= MASlow4 && MAFast3 < MASlow3 cci3 > CCI_Sell_Point && cci2 >= CCI_Sell_Point && cci1 < CCI_Sell_Point)
   
   else if  (  MAFast1 < MASlow1 && MAFast4 >= MASlow4 && MAFast3 < MASlow3 && cci1 < CCI_Sell_Point )
   
  else if (MAFast2 >= MASlow2 && MAFast1 < MASlow1  &&  MAFast3 < MASlow3 && cci1 < CCI_Sell_Point)
   
  else  ( MAFast1 < MASlow1 &&  MAFast3 < MASlow3 && cci3 > CCI_Sell_Point && cci2 >= CCI_Sell_Point && cci1 < CCI_Sell_Point )
       && ( Ticket_S == 0 || Ticket_S == -1 )
      
       && ( Ticket_L == 0 || Ticket_L == -1 ))
    {   
      Ticket_S = (OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,0,0,Comments,MAGIC,0,Blue);     
    } 
    
     
   return(0);
  }












 
      Ticket_S = (OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,0,0,Comments,MAGIC,0,Blue);    
 
Line shows three opening but only two closing brackets
 
   //  Buy entry
if(( MAFast1 > MASlow1 && MAFast4 <= MASlow4 && MAFast3 > MASlow3 && cci3 < CCI_Buy_Point && cci2 <= CCI_Buy_Point && cci1 > CCI_Buy_Point )
else if  (MAFast1 > MASlow1 && MAFast4 <= MASlow4 && MAFast3 > MASlow3 && cci1 > CCI_Buy_Point )
else if  (  MAFast2 <= MASlow2 && MAFast1 > MASlow1 && MAFast3 > MASlow3 && cci1 > CCI_Buy_Point )
else  (MAFast1 > MASlow1 && MAFast3 > MASlow3 && cci3 < CCI_Buy_Point && cci2 <= CCI_Buy_Point && cci1 > CCI_Buy_Point )
&& ( Ticket_L == 0 || Ticket_L == -1 ) 
&& ( Ticket_S == 0 || Ticket_S == -1 ))
    {  
      Ticket_L = (OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,0,0,Comments,MAGIC,0,Red);
    }

check the above mish mash, that is where the problem is.

that bunch of if else if else nonsense needs to be rewritten entirely.

keep in mind that what we are doing here is that we are writing a trading application.

a trading application that needs to run in a nonstop fashion and it needs to run in a mission critical kinda way.

we are not trying to be cute.

we are not trying to be fancy.

we are not trying to whip out a java app or a flash app in thirty minutes or less.

we do not want fancy, we want profit.

break that code down so that it is easily readable.

zero/.

 

Thanks for answering so fast. I have problem understanding the difference between If else and ||

what is the difference when writing several conditions... Do i need to use if else or it is ok to just use || .... I do not understand at all the difference between if else and || ...(-..-)

 

instead of doing this:

if(x>y && y<r && p<=t) run();

maybe do something like this:

flag=1;

if(x<=y) flag=0;

if(y>=r) flag=0;

if(p>t)flag=0;

if(flag==1) run();

see what i mean?

it is much easier to follow, tho my example above was written quickly.

always write your trading code so that an absolute idiot can follow the logic of it.

otherwise, maybe you do not fully understand your code and then it will not do what you were wanting it to do.

see what i mean?

and, there are even other ways to do what i am talking about.

if you have other questions, or if you really want for me to help you to simplify the above code of yours, just ask.

zero/.

Video: Kid Rock - American Badass

 
if( MAFast1 > MASlow1 && MAFast4 <= MASlow4 && MAFast3 > MASlow3 && cci3 < CCI_Buy_Point && cci2 <= CCI_Buy_Point && cci1 > CCI_Buy_Point )
{}
else if  (MAFast1 > MASlow1 && MAFast4 <= MASlow4 && MAFast3 > MASlow3 && cci1 > CCI_Buy_Point )
{}
else if  (  MAFast2 <= MASlow2 && MAFast1 > MASlow1 && MAFast3 > MASlow3 && cci1 > CCI_Buy_Point )
{}
else
//  (MAFast1 > MASlow1 && MAFast3 > MASlow3 && cci3 < CCI_Buy_Point && cci2 <= CCI_Buy_Point && cci1 > CCI_Buy_Point )
/*
&& ( Ticket_L == 0 || Ticket_L == -1 ) 
&& ( Ticket_S == 0 || Ticket_S == -1 ))
*/
    {  
      Ticket_L = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,0,0,Comments,MAGIC,0,Red);
    }

there are some really serious errors in your code.

lets see if we can sort them out AND in the process we will tutor you up about how it should work..

notice the curly braces{} that i inserted after the first, second and third lines..

you were doing this:

if(...)

else if(...)

else(..)

&& whatever whatever

{}

that just doesnt make sense.

if and else if and else works like this:

if(comparison) {do this}

else if(comparison) {do this}

else {do this}

let me know if you need any more help.

zero/.

 
smoknfx:

instead of doing this:

if(x>y && y<r && p<=t) run();

maybe do something like this:

flag=1;

if(x<=y) flag=0;

if(y>=r) flag=0;

if(p>t)flag=0;

if(flag==1) run();

see what i mean?

it is much easier to follow, tho my example above was written quickly.

always write your trading code so that an absolute idiot can follow the logic of it.

otherwise, maybe you do not fully understand your code and then it will not do what you were wanting it to do.

see what i mean?

and, there are even other ways to do what i am talking about.

if you have other questions, or if you really want for me to help you to simplify the above code of yours, just ask.

zero/.

Video: Kid Rock - American Badass


Thanks for helping .,. infact i am completly new to coding and i do not understand what you wrote above... I know that there are many ways to write the same coding ///

People who are used can write what i wanna write in 3 lines while im writing 30.... I know it takes efforts to be able to write .... Well yes i would appreciate if could help me but start from where you know (-..-;)

Im still a little fish swimming in the big ocean and do not know the dimension of ocean ........ What i mean is im lost....... Could you explain me how to simply to avoid 10 millions of lines if not needed... I want to use 4 ma crosses CCI and Bolinger bands to exit as you

can see with the above source.... Well thanks in any ways. Kind regards.

 

Thanks i will try to understand....... SEE what i m doing coz it seems that i do not know what i m doing myself

 

ok, fine, i did not know that you were a beginner.

lets take it slow then.

the most basic thing that you can do is this:

if(
MAFast1 > MASlow1 && 
MAFast4 <= MASlow4 && 
MAFast3 > MASlow3 && 
cci3 < CCI_Buy_Point && 
cci2 <= CCI_Buy_Point && 
cci1 > CCI_Buy_Point )
    {  
      Ticket_L = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,0,0,Comments,MAGIC,0,Red);
    }

very basic...

you do realize that && means AND, right?

if you say this in code: if(x==1 && y==1) {dothis();}

you are really saying this: if(x equals 1 and y equals 1) {dothis();}

let me know when you are with me so far, or let me know when you get confused and i will get you back on track.

IF YOU ARE A BEGINNER, DO THINGS IN A VERY BASIC WAY... DO NOT OVERLY COMPLICATE THINGS... KEEP IT SIMPLE...

 
smoknfx:

ok, fine, i did not know that you were a beginner.

lets take it slow then.

the most basic thing that you can do is this:

very basic...

you do realize that && means AND, right?

if you say this in code: if(x==1 && y==1) {dothis();}

you are really saying this: if(x equals 1 and y equals 1) {dothis();}

let me know when you are with me so far, or let me know when you get confused and i will get you back on track.


Thanks for Teaching me. Yes until now i see what you mean. There are 4 MAs crosses and CCI conditions to be completed before entering. However there are cases where these indicators complete their conditions in different timing right..

For example Fast MAs crosses first and then the Slow MAs and then the CCI... or CCI first and then the Fast MAs and the Slow MAs . Or Slow MAs first then the Fast MAs first and then the CCI last .... I need to code all cases if i want my EA to enter in everycases...

Did i code all the cases by watching to the first source that i copied on the first comment or are they just non sense... Here i wrote it with || instead of If else.... Does that make sense... it still says Unbalanced left parenthesis though,,.....

//マジックナンバーの定義
#define MAGIC  4649        

// parameter
extern double Lots = 1.0;     //取引ロット数
extern int Slip = 10;         //許容スリッページ数
extern string Comments =  ""; //コメント

extern int FastMA1_p = 34;
extern int SlowMA1_p = 34;
extern int modeMA1 = MODE_SMA;
extern int modeMA2 = MODE_EMA;
extern int MA1Cross_Timeframe = PERIOD_M15;
extern int FastMA2_p = 68;
extern int SlowMA2_p = 68;
extern int CCI_p = 20;
extern int CCI_Buy_Point = 100;
extern int CCI_Sell_Point = -100;
extern int CCI_Timeframe = PERIOD_M30;
extern int Band_p = 6;
extern int Band_Timeframe = PERIOD_M15;



//variables//
int Ticket_L = 0; 
int Ticket_S = 0; 
int Exit_L = 0;   
int Exit_S = 0;   


int start()
  {
  
  
  
    double MAFast1 = iMA(NULL, MA1Cross_Timeframe, FastMA1_p, 0, modeMA2, PRICE_CLOSE, 0);
    double MAFast2 = iMA(NULL, MA1Cross_Timeframe, FastMA1_p, 0, modeMA2, PRICE_CLOSE, 1);
    double MASlow1 = iMA(NULL, MA1Cross_Timeframe, SlowMA1_p, 0, modeMA1, PRICE_CLOSE, 0);
    double MASlow2 = iMA(NULL, MA1Cross_Timeframe, SlowMA1_p, 0, modeMA1, PRICE_CLOSE, 1);
    
    double MAFast3 = iMA(NULL, MA1Cross_Timeframe, FastMA2_p, 0, modeMA2, PRICE_CLOSE, 0);
    double MAFast4 = iMA(NULL, MA1Cross_Timeframe, FastMA2_p, 0, modeMA2, PRICE_CLOSE, 1);
    double MASlow3 = iMA(NULL, MA1Cross_Timeframe, SlowMA2_p, 0, modeMA1, PRICE_CLOSE, 0);
    double MASlow4 = iMA(NULL, MA1Cross_Timeframe, SlowMA2_p, 0, modeMA1, PRICE_CLOSE, 1);
     
     
    double cci1 = iCCI(NULL, CCI_Timeframe, CCI_p, PRICE_CLOSE, 0);
    double cci2 = iCCI(NULL, CCI_Timeframe, CCI_p, PRICE_CLOSE, 1);
    double cci3 = iCCI(NULL, CCI_Timeframe, CCI_p, PRICE_CLOSE, 2);
    
   double bands_upper1 = iBands(NULL, Band_Timeframe, Band_p,1, 0, PRICE_CLOSE, MODE_UPPER, 1);
   double bands_upper2 = iBands(NULL, Band_Timeframe, Band_p,1, 0, PRICE_CLOSE, MODE_UPPER, 2);
   double bands_lower1 = iBands(NULL, Band_Timeframe, Band_p,1, 0, PRICE_CLOSE, MODE_LOWER, 1);
   double bands_lower2 = iBands(NULL, Band_Timeframe, Band_p,1, 0, PRICE_CLOSE, MODE_LOWER, 2);
    
     
   //韮uy exit
   if(   Close[2]>= bands_upper2 && Close[0] <bands_upper1
       && ( Ticket_L != 0 && Ticket_L != -1 ))
    {     
      Exit_L = OrderClose(Ticket_L,Lots,Bid,Slip,Red);
      if( Exit_L ==1 ) {Ticket_L = 0;}
    }    
    
   //Sell exit
   if(    Close[2] <= bands_lower2 && Close[0] > bands_lower1
       && ( Ticket_S != 0 && Ticket_S != -1 ))
    {     
      Exit_S = OrderClose(Ticket_S,Lots,Ask,Slip,Blue);
      if( Exit_S ==1 ) {Ticket_S = 0;} 
    }   
    
   // buy entrt
   if(    ( MAFast1 > MASlow1 && MAFast4 <= MASlow4 && MAFast3 > MASlow3 && cci3 < CCI_Buy_Point && cci2 <= CCI_Buy_Point && cci1 > CCI_Buy_Point )//fast MA first, slow MA and cci later.
    || (MAFast1 > MASlow1 && MAFast4 <= MASlow4 && MAFast3 > MASlow3 && cci1 > CCI_Buy_Point )
    || ( ( MAFast2 <= MASlow2 && MAFast1 > MASlow1 && MAFast3 > MASlow3 && cci1 > CCI_Buy_Point )
    || (MAFast1 > MASlow1 && MAFast3 > MASlow3 && cci3 < CCI_Buy_Point && cci2 <= CCI_Buy_Point && cci1 > CCI_Buy_Point )
   
       && ( Ticket_L == 0 || Ticket_L == -1 ) 
       && ( Ticket_S == 0 || Ticket_S == -1 ))
    {  
      Ticket_L = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,0,0,Comments,MAGIC,0,Red);
    }
    
   //sell entry
   if(  (MAFast1 < MASlow1 && MAFast4 >= MASlow4 && MAFast3 < MASlow3 cci3 > CCI_Sell_Point && cci2 >= CCI_Sell_Point && cci1 < CCI_Sell_Point)
   || (  MAFast1 < MASlow1 && MAFast4 >= MASlow4 && MAFast3 < MASlow3 && cci1 < CCI_Sell_Point )
      
       ||( MAFast2 >= MASlow2 && MAFast1 < MASlow1  &&  MAFast3 < MASlow3 && cci1 < CCI_Sell_Point)
       ||( MAFast1 < MASlow1 &&  MAFast3 < MASlow3 && cci3 > CCI_Sell_Point && cci2 >= CCI_Sell_Point && cci1 < CCI_Sell_Point )
       && ( Ticket_S == 0 || Ticket_S == -1 )
      
       && ( Ticket_L == 0 || Ticket_L == -1 ))
    {   
      Ticket_S = OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,0,0,Comments,MAGIC,0,Blue);     
    } 
    
     
   return(0);
  }












Reason: