What is best reliable or universal way to detect the start of new market day (i.e. whether it's 0930 or whatever for current symbol) or week-start?
Because on some symbols the data is given exactly from mar****pen to marketclose (09:30-16:xx) , on some symbols, 24/7 hour data is given, for some symbols different hours data is given....
I always used such code in scripts (where client manually sets the hour itself and code roughly detects the opening bar):
[Display(GroupName="Parameters", Name="Monitoring Period start")] public int PeriodStart // set to 0830 by default, however user adjusts that { get; set; } [Display(GroupName="Parameters", Name="Monitoring Period end")] public int PeriodEnd // set to16830 by default, however user adjusts that { get; set; } ... OnBarUpdate: ... bool IsMar****penBar= IsFirstTickOfBar && (Time[0] >= PeriodStart && // If normal transition into open-time, like from 08:29 to 08:30 ( Time[1] < PeriodStart || // If jumped over that time from previous day, like from 21:00 to 09:00 Time[0].DayOfYear != Time[1].DayOfYear ) ); bool IsMarketAfterCloseBar= ( Time[1] < PeriodEnd && // If normal transition into open-time, like from 16:29 to 16:30 ( Time[0] >= PeriodEnd || // If jumped over that time into next day, like from 15:30 to 09:30(next day) Time[0].DayOfYear != Time[1].DayOfYear ) );
for Weekly Pivots, I reckon week start like this, but this is incorrect, because depending on timezone, it start on Sunday or Monday:
bool IsWeeklyOpenBar = IsMar****pen && Time[0].DayOfWeek ==DayOfWeek.Monday; bool IsWeeklyAfterCloseBar = IsMarketAfterCloseBar && Time[0].DayOfWeek ==DayOfWeek.Friday;
However, these codes are incorrect to detect daily/weekly market-start and market-close times (I use them to catch opening and closing prices).
Help would be appreciated.
Comment