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 NullPointStrategies, Today, 05:17 AM
      0 responses
      24 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      120 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      63 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      41 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      45 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X