Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get next session's start time, handling partial holidays & cross-time zone issues?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Get next session's start time, handling partial holidays & cross-time zone issues?

    Hello,

    How can one get NinjaTrader 8's best guess for the next session's start date and time (not the current session's start date and time, i.e. the session containing Time[0]), including handling of partial and full planned holidays, and in a way that can handle cross-time zone issues?

    I was hoping that SessionIterator.GetNextSession() would get an object containing the start date and time of the session that is predicted to occur directly after the current session if Time[0] was passed to it, but unfortunately it gets an object containing the start date and time of the current session, i.e. the session that contains the price bar with the time returned by Time[0].

    Simply adding 1 day to Time[0] of a 1-day daily bar and calling SessionIterator.GetNextSession() with the new datetime also won't work because not only could the next day be a weekend or full holiday, but SessionIterator.GetNextSession() does not get an object containing the start date and time of a session if the datetime passed to it is outside of the session, and sometimes due to partial holidays or daylight savings time, adding 1 day or 24 hours to the end time of the current session's end time (Time[0] of the current 1-day daily bar) can return a time that is after the closing time of the next session and therefore not a time that should be passed to SessionIterator.GetNextSession() if an object containing the next session's start date and time is desired.

    Thanks in advance!

    EquityTrader

    #2
    Hello EquityTrader,

    You are correct that GetNextSession() actually gets the current session of the date time supplied and not the next session.

    Unfortunately, you would need to add a minute to the current session close time to get the next session.

    This will account for holidays and weekends.

    Code:
    sessionIterator.GetNextSession(Time[0], true);
    sessionIterator.GetNextSession(sessionIterator.ActualSessionEnd.AddMinutes(1), true);
    Print(string.Format("Current bar: {0} | Get next session +1 minute actual begin bar: {1}", Time[0], sessionIterator.ActualSessionBegin));
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thank you very much for the helpful and informative response. I will give it a try.

      EquityTrader

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X