static datetime lastday=0; datetime today=iTime(NULL,PERIOD_D1,0); if(today>lastday) { Print("hello"); lastday=today; }
Plenty of different ways to do it. If your broker day is offset from your day, there are other options.
jmb: once a day, near the start of the day
- Printed is not static, therefor it will never be true.
- What about the first tick of Sunday? that's no were near midnight?
#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) ); } static datetime nextDay = 0; datetime now = TimeCurrent(); if(now >= nextDay){ nextDay = Tomorrow(); Print("Hello"); }
honest_knave and WHRoeder - my grateful thanks to you both.

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
Hello
I'm trying to do something simple, but it is eluding me due a toxic mix of a lack of knowledge and stupidity.
With this piece of code, I'd like to print to the log a simple message, once a day, near the start of the day:
I'd be most grateful if someone would enlighten me!
Thank you.