Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars.Session.GetNextBeginEnd Problem?

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

    Bars.Session.GetNextBeginEnd Problem?

    Does this method work correctly? Session template is set to 24x7

    DateTime sessionBegin,sessionEnd;

    if (Bars.SessionBreak)
    {
    Print("SessionBreak Bar: "+CurrentBar);
    Print("Bars.BarsSinceSession: "+Bars.BarsSinceSession);
    PrintTrace("DateTime of SessionBreak Bar: "+Time[0]);
    Bars.Session.GetNextBeginEnd(Time[0], out sessionBegin, out sessionEnd);
    Print("Next sessionBegin: "+sessionBegin);
    Print("Next sessionEnd: "+sessionEnd);
    }

    RESULTS IN FOLLOWING OUTPUT:

    SessionBreak Bar: 0
    Bars.BarsSinceSession: 0
    DateTime of SessionBreak Bar: 6/4/2010 12:20:21 AM
    Next sessionBegin: 6/4/2010 12:00:00 AM
    Next sessionEnd: 6/5/2010 12:00:00 AM

    Why would sessionBegin for GetNextBeginEnd be the "current" session begin time?

    #2
    Hello,

    Thank you for your forum post.

    This is working as expected. As it is 12:00 AM of the next day; NinjaTrader regards a 24 hour chart as being from 12:00 AM on day 1 to 12:00 AM. Since the begin time is the same as the end time they are paired to create a continous chart.

    In this case, the next one coming up would be the end of the 6/4 session which is 6/5 12:00AM. The begin returned is the begin of the same session of the end. So the two are always paired for the same session definition.

    So to explain this a bit better. This method returns the next SessionBegin or SessionEnd time that is coming next and then pairs with what it found. So if you needed the next session begin end time you would need to call this on the last bar of the session as then the method will return the next session Begin Time since this the next Session Time.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      I guess I shouldn't be interpreting the word NEXT so literally. If the current datetime of the session I'm looking at is 6/4/2010 12:20:21 AM, I don't understand why you would not return 6/5/2010 12:00:00 AM as the NEXT SESSION BEGIN DATETIME.

      Comment


        #4
        If you want the next session begin pass in a DateTime that would have that as a valid return for the time specified.

        Bars.Session.GetNextBeginEnd(Time[0].AddDays(1), out sessionBegin, out sessionEnd)
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        607 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        353 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        560 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        561 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X