Day() returns the day of the month from the last known server time. Month() returns the month of the year from the last known server time. And Year() returns the current year from the last known server time.
Based on those functions, you can create today's date by:
datetime Today = StrToTime(StringConcatenate(Year(), ".", Month(), ".", Day()));
or you can calculate today by:
datetime Today = TimeCurrent() - (TimeCurrent() % (PERIOD_D1 * 60)); // Today at midnight
string Date = TimeToStr(TimeCurrent(),TIME_DATE);//"yyyy.mm.dd"
Day() returns the day of the month from the last known server time. Month() returns the month of the year from the last known server time. And Year() returns the current year from the last known server time.
Based on those functions, you can create today's date by:
or you can calculate today by:
thx buddy solved
thx was helpful
Day() returns the day of the month from the last known server time. Month() returns the month of the year from the last known server time. And Year() returns the current year from the last known server time.
Based on those functions, you can create today's date by:
or you can calculate today by:
With Lotssss of thank for your helpful comment .
#define HR2400 86400 // 24 * 3600 int TimeOfDay(datetime when){ return( when % HR2400 ); } datetime DateOfDay(datetime when){ return( when - TimeOfDay(when) ); } datetime Today(){ return(DateOfDay( TimeCurrent() )); } datetime Tomorrow(){ return(Today() + HR2400); } datetime Yesterday(){ return( iTime(NULL, PERIOD_D1, 1) ); }
Devries is right this is the quickest and simplest way.
Actually none of these answers are what he asked for. Though they are what he wanted.
He asked for Today's Date. Today's date is ONE date, today.
All of the above answers produce a historical date in reference to each sequential historical bar being evaluated.
My question is more specifically what he asked for originally, which is: how do we get Today's Date only?
By this I mean the date of this post, and no previous historical dates.
Last Bar on Chart Date. In the Tester, it treats each bar as the last bar, until it advances to the next bar, but in reality there is only ONE last bar on the chart.
Some calculations could be performed on the entire sample, only after the entire data set has been processed (once the last bar on the chart is reached).
Once the last bar is reached, and the EA is actually running live, then recalculating on each bar would not be too large a processing burden. (It would have the whole time bar period in which to calculate) Recalculating on each bar during a back test though puts a large time and processing burden on the testing, making it impractical.
Thanks
thx budy it works well
. . .
All of the above answers produce a historical date in reference to each sequential historical bar being evaluated.
. . .
I don't think that is a correct statement. (Remember: TimeCurrent() returns "the last known server time (time of incoming of the latest quote) . . ..")
. . .
My question is more specifically what he asked for originally, which is: how do we get Today's Date only?
By this I mean the date of this post, and no previous historical dates.
. . .
- 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 guys.
i'm studying as noob.
plz help me how to get today's date? as "d=10" "m=10" y="2013"?