Ayuda para encontrar un paréntesis izquierdo desequilibrado

 

Podría alguien ayudarme a encontrar este error de paréntesis izquierdo desequilibrado.... he probado todas las combinaciones pero nunca se resuelve....

y también un consejo si todos los casos están bien escritos ....

he intentado escribir los cruces de 4 ma y cci por encima de 100 o -100 para comprar y vender ... ¡Gracias de antemano!

//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);    
 
La línea muestra tres paréntesis de apertura pero sólo dos de cierre
 
   //  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);
    }

revisa la mezcla anterior, ahí es donde está el problema.

ese montón de tonterías de if else if else necesita ser reescrito por completo.

ten en cuenta que lo que estamos haciendo aquí es que estamos escribiendo una aplicación de comercio.

una aplicación de comercio que necesita ejecutarse de manera ininterrumpida y necesita ejecutarse de una manera de misión crítica.

no estamos tratando de ser lindo.

no estamos tratando de ser elegantes.

no estamos tratando de hacer una aplicación java o una aplicación flash en treinta minutos o menos.

no queremos ser elegantes, queremos beneficios.

Descomponga ese código para que sea fácilmente legible.

cero/.

 

Gracias por responder tan rápido. Tengo problemas para entender la diferencia entre If else y ||.

¿cuál es la diferencia cuando se escriben varias condiciones? ¿Necesito usar if else o está bien usar sólo || .... No entiendo en absoluto la diferencia entre if else y || ...(-..-)

 

en lugar de hacer esto

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

tal vez hacer algo como esto

flag=1;

if(x<=y) flag=0;

if(y>=r) flag=0;

if(p>t)flag=0;

if(flag==1) run();

¿ves lo que quiero decir?

es mucho más fácil de seguir, aunque mi ejemplo anterior fue escrito rápidamente.

siempre escriba su código de operaciones de manera que un idiota absoluto pueda seguir la lógica del mismo.

de lo contrario, tal vez no entienda completamente su código y entonces no hará lo que usted quería que hiciera.

¿ves lo que quiero decir?

y, hay incluso otras maneras de hacer lo que estoy hablando.

si tienes otras preguntas, o si realmente quieres que te ayude a simplificar tu código, sólo tienes que preguntar.

cero/.

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);
    }

hay algunos errores realmente graves en su código.

Vamos a ver si podemos resolverlos Y en el proceso vamos a tutorizar a usted acerca de cómo se debe trabajar ...

Fíjate en las llaves{} que he insertado después de la primera, segunda y tercera línea...

que estabas haciendo esto:

if(...)

else if(...)

else(..)

&& lo que sea

{}

que simplemente no tiene sentido.

if y else if y else funciona así

if(comparación) {hacer esto}

else if(comparación) {hacer esto}

else {hacer esto}

hazme saber si necesitas más ayuda.

cero/.

 
smoknfx:

en lugar de hacer esto

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

tal vez hacer algo como esto

flag=1;

if(x<=y) flag=0;

if(y>=r) flag=0;

si(p>t)flag=0;

if(flag==1) run();

¿ves lo que quiero decir?

es mucho más fácil de seguir, aunque mi ejemplo anterior fue escrito rápidamente.

siempre escriba su código de operaciones de manera que un idiota absoluto pueda seguir la lógica del mismo.

de lo contrario, tal vez no entienda completamente su código y entonces no hará lo que usted quería que hiciera.

¿ves lo que quiero decir?

y, hay incluso otras maneras de hacer lo que estoy hablando.

si tienes otras preguntas, o si realmente quieres que te ayude a simplificar tu código, sólo tienes que preguntar.

cero/.

Video: Kid Rock - American Badass


Gracias por la ayuda... de hecho soy completamente nuevo en la codificación y no entiendo lo que has escrito arriba... Sé que hay muchas maneras de escribir la misma codificación ///

La gente que está acostumbrada puede escribir lo que yo quiero escribir en 3 líneas mientras yo escribo 30.... Sé que se necesita esfuerzo para poder escribir .... Bueno sí agradecería que me ayudaras pero empieza por donde sabes (-..-;)

Todavía soy un pequeño pez nadando en el gran océano y no conozco la dimensión del océano ........ Lo que quiero decir es que estoy perdido ....... Podrías explicarme como simplemente evitar 10 millones de líneas si no son necesarias... Quiero utilizar 4 ma cruces CCI y Bolinger bandas para salir como se

puede ver con la fuente anterior.... Bueno gracias de cualquier manera. Saludos cordiales.

 

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, bien, no sabía que eras un principiante.

vamos a ir despacio entonces.

lo más básico que puedes hacer es esto:

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);
    }

muy básico...

te das cuenta de que && significa Y, ¿verdad?

si dices esto en código: if(x==1 && y==1) {dothis();}

realmente estás diciendo esto: if(x es igual a 1 e y es igual a 1) {dothis();}

avísame cuando estés conmigo hasta ahora, o avísame cuando te confundas y te pondré al día.

SI ERES PRINCIPIANTE, HAZ LAS COSAS DE FORMA MUY BÁSICA... NO COMPLIQUES DEMASIADO LAS COSAS... HAZLO SIMPLE...

 
smoknfx:

Vale, bien, no sabía que eras un principiante.

vamos a ir despacio entonces.

lo más básico que puedes hacer es esto:

muy básico...

te das cuenta de que && significa Y, ¿verdad?

si dices esto en código: if(x==1 && y==1) {dothis();}

realmente estás diciendo esto: if(x es igual a 1 e y es igual a 1) {dothis();}

hazme saber cuando estés conmigo hasta ahora, o hazme saber cuando te confundas y te volveré a poner en el camino.


Gracias por enseñarme. Sí hasta ahora veo lo que quieres decir. Hay 4 cruces de MAs y las condiciones de CCI para ser completado antes de entrar. Sin embargo, hay casos en los que estos indicadores completan sus condiciones en diferentes tiempos derecho..

Por ejemplo las MAs rápidas cruzan primero y luego las MAs lentas y luego el CCI... o el CCI primero y luego las MAs rápidas y las MAs lentas . O las MAs lentas primero y luego las MAs rápidas primero y luego el CCI por último .... Necesito codificar todos los casos si quiero que mi EA entre en todos los casos...

He codificado todos los casos mirando la primera fuente que copié en el primer comentario o simplemente no tienen sentido... Aquí lo escribí con || en lugar de If else.... ¿Tiene sentido ... todavía dice paréntesis izquierda desequilibrada sin embargo,,.....

//マジックナンバーの定義
#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);
  }