Download MetaTrader 5

if condition doesn't work properly

To add comments, please log in or register
Speed up MQL5 Cloud Network. Install Strategy Tester Agent!
cpr
26
cpr 2016.10.27 20:15 

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 2016.10.27 20:21  
I'm using mql4
Keith Watford
Moderator
9624
Keith Watford 2016.10.27 20:41  

= is not a boolean comparison

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

the same in all the if's

cpr
26
cpr 2016.10.27 23:24  
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