Newbie - help needed

 

Hi, I am new to this MQL4. I am trying to develop an expert advisor. I am trying to display an alert message when some conditions are met and when a new candle stick is started. But the alert message is displaying always. Is there any way an alert message is displayed whenever an new candle stick started. The alert message should display only one time and the next alert message when another new candlestick is started. Please help.

 
subbu:

Hi, I am new to this MQL4. I am trying to develop an expert advisor. I am trying to display an alert message when some conditions are met and when a new candle stick is started. But the alert message is displaying always. Is there any way an alert message is displayed whenever an new candle stick started. The alert message should display only one time and the next alert message when another new candlestick is started. Please help.

I think you could flag the time if conditions are met. Here's the algoritm. I havent tested it. I just hope that the way i did datetime comparison works fine.

//in global section 
datetime flagTime = NULL;

.....
.....

if(<condition is met> && flagTime == NULL) {
    flagTime = Time[0]; //remember new candle open time

    //DO SOMETHING HERE
}
else if(flagTime != Time[0]) {
    flagTime = NULL; //reset flag
}
Reason: