Aide pour trouver une parenthèse gauche non équilibrée

 

Quelqu'un peut-il m'aider à trouver cette erreur de parenthèse gauche déséquilibrée.... j'ai essayé moi-même toutes les combinaisons mais ça ne résout jamais....

et aussi un conseil si tous les cas sont correctement écrits ....

J'ai essayé d'écrire les 4 ma crosses et cci au-dessus de 100 ou -100 pour acheter et vendre ... Merci d'avance !

//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 ligne présente trois crochets d'ouverture mais seulement deux crochets de fermeture.
 
   //  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);
    }

Vérifiez le mish mash ci-dessus, c'est là que le problème est.

Ce tas d'absurdités de type "si, sinon, sinon" doit être entièrement réécrit.

Gardez à l'esprit que ce que nous faisons ici, c'est que nous écrivons une application de trading.

une application de trading qui doit fonctionner de manière ininterrompue et qui doit fonctionner d'une manière critique pour la mission.

Nous n'essayons pas d'être mignons.

nous n'essayons pas d'être fantaisistes.

Nous n'essayons pas de créer une application Java ou une application Flash en trente minutes ou moins.

Nous ne voulons pas de fantaisie, nous voulons du profit.

décomposer ce code pour qu'il soit facilement lisible.

zéro/.

 

Merci d'avoir répondu si rapidement. J'ai du mal à comprendre la différence entre If else et ||.

quelle est la différence lorsqu'on écrit plusieurs conditions... Dois-je utiliser if else ou est-il possible d'utiliser simplement || .... Je ne comprends pas du tout la différence entre if else et || ...(-..-)

 

au lieu de faire ceci

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

peut-être faire quelque chose comme ceci

flag=1 ;

si x<=y) drapeau=0 ;

si(y>=r) flag=0 ;

si (p>t) flag=0 ;

si(flag==1) run() ;

vous voyez ce que je veux dire ?

c'est beaucoup plus facile à suivre, bien que mon exemple ci-dessus ait été écrit rapidement.

écrivez toujours votre code de trading de façon à ce qu'un idiot absolu puisse en suivre la logique.

sinon, vous ne comprenez peut-être pas complètement votre code et il ne fera pas ce que vous vouliez qu'il fasse.

Vous voyez ce que je veux dire ?

et, il y a même d'autres façons de faire ce dont je parle.

si vous avez d'autres questions, ou si vous voulez vraiment que je vous aide à simplifier votre code ci-dessus, n'hésitez pas.

zéro/.

Vidéo : 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);
    }

il y a de sérieuses erreurs dans votre code.

Voyons voir si nous pouvons les résoudre ET dans le processus, nous allons vous enseigner comment cela devrait fonctionner...

remarquez les accolades{} que j'ai insérées après les première, deuxième et troisième lignes...

tu faisais ça :

if(...)

else if(...)

autre(..)

&& whatever whatever

{}

cela n'a pas de sens.

if et else if et else fonctionnent comme ceci :

if(comparaison) {faire ceci}

else if(comparaison) {faire ceci}

sinon {faire ceci}

Faites-moi savoir si vous avez besoin d'aide.

zéro/.

 
smoknfx:

au lieu de faire ceci

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

faites peut-être quelque chose comme ceci

flag=1 ;

si x<=y) drapeau=0 ;

si(y>=r) flag=0 ;

si (p>t) flag=0 ;

si(flag==1) run() ;

vous voyez ce que je veux dire ?

c'est beaucoup plus facile à suivre, bien que mon exemple ci-dessus ait été écrit rapidement.

écrivez toujours votre code de trading de façon à ce qu'un idiot absolu puisse en suivre la logique.

sinon, vous ne comprenez peut-être pas complètement votre code et il ne fera pas ce que vous vouliez qu'il fasse.

Vous voyez ce que je veux dire ?

et, il y a même d'autres façons de faire ce dont je parle.

si vous avez d'autres questions, ou si vous voulez vraiment que je vous aide à simplifier votre code ci-dessus, n'hésitez pas.

zéro/.

Vidéo : Kid Rock - American Badass


Merci pour votre aide... En fait, je suis totalement novice en matière de codage et je ne comprends pas ce que vous avez écrit ci-dessus... Je sais qu'il y a plusieurs façons d'écrire le même codage ///

Les personnes habituées peuvent écrire ce que je veux écrire en 3 lignes alors que j'en écris 30..... Je sais que cela demande des efforts pour être capable d'écrire .... Eh bien oui, j'apprécierais si vous pouviez m'aider mais commencez par là où vous savez (-..- ;)

Je suis toujours un petit poisson qui nage dans le grand océan et je ne connais pas la dimension de l'océan ........ Ce que je veux dire c'est que je suis perdu....... Pourriez-vous m'expliquer comment faire simplement pour éviter 10 millions de lignes si ce n'est pas nécessaire... Je veux utiliser les croisements CCI 4 ma et les bandes de Bolinger pour sortir comme vous

comme vous pouvez le voir avec la source ci-dessus.... Merci en tout cas. Bien à vous.

 

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, je ne savais pas que tu étais un débutant.

Allons-y doucement alors.

La chose la plus basique que vous pouvez faire est celle-ci :

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

très basique...

vous réalisez que && signifie ET, n'est-ce pas ?

si vous dites ceci en code : if(x==1 && y==1) {dothis();}

tu dis en réalité ceci : if(x equals 1 and y equals 1) {dothis();}

faites-moi savoir si vous êtes d'accord avec moi jusqu'à présent, ou faites-moi savoir si vous êtes confus et je vous remettrai sur la bonne voie.

SI VOUS ÊTES UN DÉBUTANT, FAITES LES CHOSES DE MANIÈRE TRÈS BASIQUE... NE COMPLIQUEZ PAS TROP LES CHOSES... RESTEZ SIMPLE...

 
smoknfx:

Ok, bien, je ne savais pas que tu étais un débutant.

Allons-y doucement alors.

La chose la plus basique que vous pouvez faire est celle-ci :

très basique...

vous réalisez que && signifie ET, n'est-ce pas ?

si vous dites ceci en code : if(x==1 && y==1) {dothis();}

tu dis en réalité ceci : if(x equals 1 and y equals 1) {dothis();}

Faites-moi savoir quand vous êtes avec moi jusqu'à présent, ou faites-moi savoir quand vous êtes confus et je vous remettrai sur la bonne voie.


Merci de m'avoir appris. Oui, jusqu'à maintenant, je comprends ce que vous voulez dire. Il y a 4 croisements de MAs et des conditions CCI à remplir avant d'entrer. Cependant, il y a des cas où ces indicateurs remplissent leurs conditions dans des délais différents...

Par exemple les Fast MAs croisent d'abord et ensuite les Slow MAs et ensuite le CCI... ou CCI d'abord et ensuite les Fast MAs et les Slow MAs . Ou les Slow MAs d'abord puis les Fast MAs d'abord et enfin le CCI en dernier .... Je dois coder tous les cas si je veux que mon EA entre dans tous les cas...

Est-ce que j'ai codé tous les cas en regardant la première source que j'ai copiée dans le premier commentaire ou est-ce qu'ils n'ont pas de sens ? Ici je l'ai écrit avec || au lieu de If else.... Est-ce que cela a un sens... il y a toujours le message "Parenthèse gauche déséquilibrée", .....

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












Raison: