bool NewDay() { static datetime PrevDay; if(PrevDay < iTime(NULL, PERIOD_D1, 0)) { PrevDay = iTime(NULL, PERIOD_D1, 0); return(true); } else { return(false); } }correct code should be this?
if(PrevDay < iTime(NULL, PERIOD_D1, 0))
will fail to recalc for indicator on refresh that restarts from oldest bar. That why I used '!=' not equal
will fail to recalc for indicator on refresh that restarts from oldest bar. That why I used '!=' not equal
Sorry, I don't get what you mean. Please explain more.
(the following is my understanding anyway)
Let's say that you do a Refresh to update some missing bars.
Then deinit(), init(), and start (with IndicatorCounted() of 0) will happen.
Any variables set up/initialised in init() will be just fine.
However, static variables will NOT be initialised again, so a check of PrevDay against iTime will not trigger recalcs, as Prevday will be never be lower than any bars, until a new latest bar is created
(the following is my understanding anyway)
Let's say that you do a Refresh to update some missing bars.
Then deinit(), init(), and start (with IndicatorCounted() of 0) will happen.
Any variables set up/initialised in init() will be just fine.
However, static variables will NOT be initialised again, so a check of PrevDay against iTime will not trigger recalcs, as Prevday will be never be lower than any bars, until a new latest bar is created
I understand you now.
Thanks for the information.
use something like
code just typed; not checked or compiled, etc
currentDay != iTime(NULL, PERIOD_D1, 0)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I have a function to store some daily data and this need to be refresh once a new day starts.
My EA is put on 1H chart
How to go about doing so?
Thanks