Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 05:11:51 +0000



[Programming Help] - Looking for a way to get the next trading day start session time

View Count: 417

[2021-04-22 21:30:41]
User785302 - Posts: 8
Hello

I am successfully using n_ACSIL::s_ChartSessionTimes to get the .StartTime which is the RTH time. e.g. usually 8:30 am CST. this works fine during realtime updating but during initial loading I can't affort it performance wise and hence am looking for way to "jump" directly to the next trading day.I discovered sc.GetTradingDayStartDateTimeOfBar but that takes me to the beginning of the evening session and when I add a day on Friday it takes me to Saturday, which is not a trading day.

I tried this here


PDT_NextUpdate = SCDateTime(sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[Index]).GetDate(), PDT_DailyUpdateTime.GetTimeInSeconds()) + SCDateTime::DAYS(1);
// PDT_DailyUpdateTime is SCDateTime that stores my daily update time for a calculation.
and then this variation to take it from session end + a few seconds

PDT_NextUpdate = SCDateTime(sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[sc.GetNearestMatchForSCDateTime(sc.ChartNumber, SCDateTime(sc.BaseDateTimeIn[Index].GetDate(), PDT_SessionEndTime.GetTimeInSeconds() + 61))]).GetDate(), PDT_DailyUpdateTime.GetTimeInSeconds()) + SCDateTime::DAYS(1);
// PDT_SessionEndTime is a SCDateTime that stores the RTH SessionEndTime (from n_ACSIL::s_ChartSessionTimes.EndTime.

Hope you understand my problem. Ideally, I'd like a function sc.GetNextTradingDate(SCDateTime) that would return an SCDateWith the nextTradingDate. Basically, it's a function that adds 1 day but also takes into consideration weekends and perhaps public holidays where no trading takes place.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account