How substract 1 day from TimeDayOfYear() ?
(TimeDayOfYear(Date1) -1 day) is causing error. What is correct syntax to substract 1 day from TimeDayOfYear() ?
Tried the following but error too :
if((TimeDayOfYear(Date1) - (PERIOD_D1 * 60)) == TimeDayOfYear(TimeCurrent()))
Found the solution :
if((TimeDayOfYear(Date1 - 86400)) == TimeDayOfYear(TimeCurrent())) { Print("It is 1 day before Today"); }
Print("It is 1 day before Today");
this is so wrong lol. How to make the comparison including year and month?
Ok here is the solution :
if((TimeDayOfYear(Date1 - 86400)) == TimeDayOfYear(TimeCurrent()) && (TimeMonth(Date1)) == TimeMonth(TimeCurrent()) && (TimeYear(Date1)) == TimeYear(TimeCurrent())) { Print("It is 1 day before Today"); }
Or
if((TimeDay(Date1 - 1 )) == TimeDay(TimeCurrent()) && (TimeMonth(Date1)) == TimeMonth(TimeCurrent()) && (TimeYear(Date1)) == TimeYear(TimeCurrent())) { Print("It is 1 day before Today"); }
yesterday = today - 1
Find bar of the same time one day ago - MQL4 programming forum (2017)
(TimeDayOfYear(Date1) -1 day) is causing error. What is correct syntax to substract 1 day from TimeDayOfYear() ?
input DateTime Date1; MqlDateTime STime; TimeToStruct(Date1,STime); int dayIWant=STime.day_of_week-1;
You do not want one day ago, you want one trading day ago. Think market holidays and weekends.
Find bar of the same time one day ago - MQL4 programming forum (2017)
- I am not trolling anything.
- Just because OP said what he thinks he needs doesn't mean that is what he actually wants.
How To Ask Questions The Smart Way. (2004)
The XY Problem - By pointing a different interpretation of his question, I may be saving him, (and others,) a long road of debugging.
(TimeDayOfYear(Date1) -1 day) is causing error. What is correct syntax to substract 1 day from TimeDayOfYear() ?