Give an alert at a specific time or after a daily close

 

Hi,

I wonder how I can specify an alert at a specific time in the day or an alert after a daily close. Can someone help me with that?

The problem I think is that the functions hour(), minutes() can not be used because it only works when the script/ea loads.

I am going to use it in an EA.

 
herbertioz:

Hi,

I wonder how I can specify an alert at a specific time in the day or an alert after a daily close. Can someone help me with that?

The problem I think is that the functions hour(), minutes() can not be used because it only works when the script/ea loads.

I am going to use it in an EA.

You can use TimeHour() and TimeMinute() with TimeCurrent() to get the current hour and current minute and then alert as appropriate.
 
RaptorUK:
You can use TimeHour() and TimeMinute() with TimeCurrent() to get the current hour and current minute and then alert as appropriate.

Can this code work?
if ( TimeHour(TimeCurrent()) == 18 && TimeMinute(TimeCurrent()) == 43 ) 
{
 Alert ("It worked!");
}
 
herbertioz:
Can this code work?

Yes, and it will alert for every tick that occurs during 6:43 pm, you probably only want one alert ?
 
RaptorUK:

Yes, and it will alert for every tick that occurs during 6:43 pm, you probably only want one alert ?

Very good, I can make a boolean variable so that I do get only one alert. Thanks for help, Raptor UK!
 
herbertioz:

Very good, I can make a boolean variable so that I do get only one alert. Thanks for help, Raptor UK!

One other thing . . . if there is no tick during 6:43 pm you won't get an alert, you might want to check for . . .

if ( TimeHour(TimeCurrent()) == 18 && TimeMinute(TimeCurrent()) >= 43 ) 
{
 Alert ("It worked!");
}

. . . and the reset your bool when the hour is > 18

Reason: