Yes, but I want to show day beginning at midnight, EST, not 5:00 p.m. EST.
/** This structure just contains static functions for name space control. */ struct Date_Time{ // used in chart_time and utility #define SECONDS int ///< Difference between two datetimes. #define HR2400 86400 // PERIOD_D1 * 60 = 24 * 3600 static SECONDS time(datetime when=0){ return SECONDS((when == 0) ? TimeCurrent() : when) % HR2400; } static datetime date(datetime when=0){ return ((when == 0) ? TimeCurrent() : when) - time(when); } static datetime tomorrow( datetime when=0){ return date((when == 0) ? TimeCurrent() : when) + HR2400; } /// Returns previous trading day. static datetime yesterday(datetime when=0) /**< Previous relative to when.*/{ if(when==0) when = TimeCurrent(); // Make sure I have daily history. download_history(_Symbol, PERIOD_D1, __FUNCTION__); INDEX iD1 = iBarShift(NULL, PERIOD_D1, when); // Find today. return iTime(NULL, PERIOD_D1, iD1 + 1); // Return yesterday. } /// Converts a day of week to a string. static string as_string(ENUM_DAY_OF_WEEK dow, ///<[in] Day of the week. COUNT nChar=9) /**<[in] Number of characters to * return, e.g.\ 3 outputs Sun. */{ static const string txt[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; return StringSubstr(txt[dow], nChar); } private: char onebyte;///< Prevent "struct has no members, size assigned to 1 byte }; : #define EST5 -18000 // 5*3600 datetime chartNow = Time[0]; datetime estNow = chartNow + EST5; datetime estMidnight = Date_Time::date(estNow); datetime chartMidnight = midnight - EST5; ObjectDelete("DayStart"); ObjectCreate("DayStart",OBJ_VLINE,0,chartMidnight,0);
may be you just need (always today's 00:00 broker time):
ObjectCreate("DayStart",OBJ_VLINE,0,iTime(_Symbol,PERIOD_D1,0)+OffSet,0);
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
Can anyone show me how to place a VLine at the start of the day, for a specific time. I am on EST and would like to show, on my chart, the start of the day. Which is midnight. My chart time is 5 hours ahead of EST.
Above is the code I generally use, for VLine. I can change the value of Time[0] to a different bar number, but was hoping that there was a way to set VLine by time.
Thanks!