Download MetaTrader 5

if condition doesn't work properly

To add comments, please log in or register
cpr
26
cpr  

Hi,

I'm trying to do an if condition but it doesn't work. It always results in condition as candle1=1 even if for each timer I change this variable. Where I'm going wrong?

Thanks in advance

Regards

int candle1=0;

int OnInit()
  {

EventSetTimer(Timer);

//---
   return(INIT_SUCCEEDED);
  }

void OnTimer()
  {

Analize();
}


void Analize()
{
if (candle1=0)
{
Alert("1");
candle1=1; 
}
else if (candle1=1)
{
Alert("2");
candle1=2; 
}
else if (candle1=2)
Alert("3"); 
candle1=3;
}

else if (candle1=3)
{
Alert("4"); 
candle1=4;

}

else if (candle1=4)
{
Alert("4"); 
}
}
cpr
26
cpr  
I'm using mql4
Keith Watford
Moderator
10646
Keith Watford  

= is not a boolean comparison

if (candle1=0)
// Should be
if (candle1==0)

the same in all the if's

cpr
26
cpr  
GumRai:

= is not a boolean comparison

the same in all the if's



Great! Thanks a lot!
To add comments, please log in or register