Send Email On Pre Set Time not Working, event is not firing !

 
I have this function in start...IT DOES NOT FIRE !!!
- Its on a EA, with all common EA properties clicked on !
- Tick action from chart occured during this time frame.

Why does it not send an email.

The OK Variable is there to make sure it ony sends an email once, and not on every tick !



void Start()
{
EmailAction();

}


void EmailAction()
{
int OK1 = 0;

// If local time is 4 pm and minute is 0 ( ie first 60 seconds of the hour) then send email.

if(TimeHour(TimeLocal()) == 16 && TimeMinute(TimeLocal()) ==0 && OK1 != 1)
{
SendMail( "TEST_Status_"+TimeToStr(TimeLocal(),TIME_DATE|TIME_MINUTES), "TEST" );
OK1 = 1;
}
else
OK1 = 0;

return(0);
}
 
Usually new tick does not come to the first minute of each hour. Use in addition Print () to be convinced of it.
void EmailAction()
{
int OK1 = 0;

// If local time is 4 pm and minute is 0 ( ie first 60 seconds of the hour) then send email.

if(TimeHour(TimeLocal()) == 16 && TimeMinute(TimeLocal()) =0 && OK1 != 1)
{
SendMail( "TEST_Status_"+TimeToStr(TimeLocal(),TIME_DATE|TIME_MINUTES), "TEST" );
Print("Attempt to send mail at ",TimeToStr(TimeCurrent()));
OK1 = 1;
}
else
OK1 = 0;

return(0);
}