samuelgo:
The time functions return a datetime type variable (number of seconds since 1/1/70) so you should convert your midnight and midnight:05 times to datetimes, have a read of this: Midnight
Thanks...
So would
if ( TimeLocal() >= '00:00:00' && TimeLocal() <= '00:05:00')
work?
Im new to this, cant get my head around the time functions and order functions.
Sam.
Thanks!
samuelgo: I need to check the time is between midnight and 12:05 (GMT +2) in an IF statement.
|
#define HR2400 (PERIOD_D1 * 60) // 86400 = 24 * 3600 int TimeOfDay(datetime when=0){ if(when == 0) when = TimeCurrent(); return( when % HR2400 ); } datetime DateOfDay(datetime when=0){ if(when == 0) when = TimeCurrent(); return( when - TimeOfDay(when) ); } //datetime Tomorrow( datetime when=0){ if(when == 0) when = TimeCurrent(); // return(DateOfDay(when) + HR2400); } //datetime Yesterday(datetime when=0){ if(when == 0) when = TimeCurrent(); // int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1); // return( iTime(NULL, PERIOD_D1, iD1) ); } : #define HR0005 300 // 12:05 AM datetime now = TimeCurrent(); // or local or gmt if(TimeOfDay(now) < HR0005) ... |
It's not particularly elegant, but I use the following to get midnight of the current date (or whichever date you wish to substitute):
datetime Midnight = (datetime)TimeToStr(TimeCurrent(),TIME_DATE);
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi, I need to check the time is between midnight and 12:05 (GMT +2) in an IF statement.
How could I do this??
Thanks, sam.