error: unexpected token '=='

 

what's wrong in this code?

if( ( (adxStatus == bull) || (adxStatus == neutral) ) && (isADXForSell == true) ){
      adxStatus = bear;
      isADXReady = true;
}else if( ( (adxStatus == bear) || (adxStatus == neutral) ) && (isADXForBuy == true) ){
      adxStatus = bull;
      isADXReady = true;
}

refers to the first if


thanks

 
CaneRandagio:

what's wrong in this code?

refers to the first if


thanks

No syntax error in that code, you probably forgot to add a semicolon or close a brace in other part of the code.

 
Alexandre Borela #:

No syntax error in that code, you probably forgot to add a semicolon or close a brace in other part of the code.

if I comment the block of code in question it compiles successfully.
 
CaneRandagio #:
if I comment the block of code in question it compiles successfully.
I tried your code in isolation and it compiles file, the issue is elsewhere.

Post the rest of the code to see if I or another member can spot anything wrong.
 
CaneRandagio: what's wrong in this code? refers to the first if

The problem is with the code above your if.

 
void OnTick(){
   
   createBuffers();
   
   //open position
   if(!isInTheMarket){
      if(isADXSetupForBuy() && isADXForBuy){
         buy();
      }else if(isADXSetupForSell() && isADXForSell){
         sell();
      }
   }
   
   //change trailing stop
   if(isInTheMarket && isTimeToChangeTrailingStop())
      changeTrailingStop();
   
   //break heaven
   if(isTimeToGoToBreakHeaven())
      goToBreakHeaven();
   
   // fix the variables
   if( isPositionOpen() ){
   
      isInTheMarket = true;
      
      if( positionInfo.PositionType() == POSITION_TYPE_BUY )
         isInBuy = true;
      else if( positionInfo.PositionType() == POSITION_TYPE_SELL )
         isInSell = true;
   }else{
      isInTheMarket = false;
      isInBuy = false;
      isInSell = false;
      isBreakHeaven = false;
   }   
   
   if(adxDIPBuffer[0] > adxDIMBuffer[0]){
      isADXForBuy = true;
      isADXForSell = false;
   }else if(adxDIPBuffer[0] < adxDIMBuffer[0]){
      isADXForBuy = false;
      isADXForSell = true;
   }else{
      isADXForBuy = false;
      isADXForSell = false;
   }
   
   //set adxStatus and isADXReady when dip and dim cross themself
   if( ( (adxStatus == bull) || (adxStatus == neutral) ) && (isADXForSell == true) ){
      adxStatus = bear;
      isADXReady = true;
   }else if( ( (adxStatus == bear) || (adxStatus == neutral) ) && (isADXForBuy == true) ){
      adxStatus = bull;
      isADXReady = true;
   }
   
}
 
CaneRandagio #:

The error is not in this block of code, it's somewhere else. My guess is that you forgot to add a semicolon to the end of a class or structure as
it can generate cryptic errors like this.

I also recommend that you use a source control system like Git, this way, in the future, if you get a similar problem  you'll be able to pinpoint
all the parts of the project you changed that might have caused the issue.

 
Alexandre Borela #:

The error is not in this block of code, it's somewhere else. My guess is that you forgot to add a semicolon to the end of a class or structure as
it can generate cryptic errors like this.

I also recommend that you use a source control system like Git, this way, in the future, if you get a similar problem  you'll be able to pinpoint
all the parts of the project you changed that might have caused the issue.

I really don't know, I repeat ... if I comment on that little piece of code where the error is reported to me, everything is compiled normally.

I also tried to create a function where to put that code, same errors.
this is the github repository:

https://github.com/CaneRandagio1983/adx-ea


thanks guys

 

adxStatus is a type. The expression should take a variable of that type.

enum ADXStatus{neutral,bull,bear}adxStatus;
 
Ernst Van Der Merwe #:

adxStatus is a type. The expression should take a variable of that type.

lol, thanks! it works now!
Reason: