Ok. So I am trying to create a test that identifies if it is a new day. I am trying to do this through testing, on M1, to see if the date of the previous bar is less than the current bar. I have started with this:
Will this return the dates for each of the bars indicated?
I have complied, and for some reason, (which I cannot understand as of yet) it gives me an error saying '=' - incompatible types. It does this for the Yesterday =, rather than then Today =.
Why would this be? Is this a good way of identifying a new day if the following test below is used?
Does anyone have any suggestions? As some may know, I am VERY new to coding, so if you could explain it, I may be able to learn, rather than end up confused!
Thanks.
TimeToStr returns what kind of variable ? what kind of variable does iTime return ? why would the date/time value for bar 1 ever not be less than the value for bar 0 ?
Ok. Thanks for the hints, I just changed it to a string value, which appears to report the date I am after. Its reporting the dates, rather than the times. There will be one minute every day, in which the dates do not match, and the previous bar will be less than the current bar.
string Yesterday = TimeToStr(iTime(Symbol(),PERIOD_M1,1),TIME_DATE); string Today = TimeToStr(iTime(Symbol(),PERIOD_M1,0),TIME_DATE);
One question I do have is can an if(...) statement test using a string value?
if(Yesterday < Today)
{
One question I do have is can an if(...) statement test using a string value?
But me i just look out the window if i see sun i know its a new day
Ok. So I am trying to create a test that identifies if it is a new day. ...
static datetime today; if (today != iTime (Symbol(), PERIOD_D1, 0)) { today = iTime (Symbol(), PERIOD_D1, 0); Print ("Its a new day ",TimeToStr(iTime (Symbol(), PERIOD_D1, 0))); }
static int reset; if(Hour()==0&&reset==1){ Alert("Happy new day!"); reset=0; } if(Hour!=0) reset=1;
Ha ha mine is shorter
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Ok. So I am trying to create a test that identifies if it is a new day. I am trying to do this through testing, on M1, to see if the date of the previous bar is less than the current bar. I have started with this:
Will this return the dates for each of the bars indicated?
I have complied, and for some reason, (which I cannot understand as of yet) it gives me an error saying '=' - incompatible types. It does this for the Yesterday =, rather than then Today =.
Why would this be? Is this a good way of identifying a new day if the following test below is used?
if(Yesterday < Today) {
Does anyone have any suggestions? As some may know, I am VERY new to coding, so if you could explain it, I may be able to learn, rather than end up confused!
Thanks.