Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SessionBegin changed

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

    SessionBegin changed

    In NT6.5 I used this call to produce a new DateTime instance:

    new DateTime(Bars.SessionBegin.Year, Bars.SessionBegin.Month, Bars.SessionBegin.Day, Bars.SessionEnd.Hour, Bars.SessionEnd.Minute, Bars.SessionEnd.Second);

    In NT7 I am getting the following error:

    'NinjaTrader.Data.Bars' does not contain a definition for 'SessionBegin' and no extension method 'SessionBegin' accepting a first argument of type 'NinjaTrader.Data.Bars' could be found (are you missing a using directive or an assembly reference?)

    What's the construct in NT7?

    Thanks,

    Mole

    #2
    SesionBegin/End are deprecated. We now have possibility of different sessions each day of the week, or even multiple sessions on same day. See the Help guide and the code breaking changes document:-

    http://www.ninjatrader-support2.com/vb/showthread.php?t=21016

    Comment


      #3
      Originally posted by MJT View Post
      SessionBegin/End are deprecated. We now have possibility of different sessions each day of the week, or even multiple sessions on same day. See the Help guide and the code breaking changes document:-

      http://www.ninjatrader-support2.com/vb/showthread.php?t=21016
      I have read that document but it doesn't help me produce the right call here. What would you suggest I use instead?

      Comment


        #4
        There may be improvements in getting session times in the next release, so I suggest you may want to wait for that-


        In the meantime if you only want the current (realtime) session then you can use Bars.Session.NextBeginTime, but it will not give you any historical session times.
        If you know the location of the session in the SessionsOfDay array then you can use Bars.Session.SessionsOfDay[x].BeginTime, however it will return an integer not a DateTime.
        Bars.Session.SessionsOfDay[x].BeginDay returns a DayOfWeek which will require additional logic to convert to a Date.

        The approach I took was to loop through the SessionsOfDay array to find a DayOfWeek that matched the bar being processed (Time[0].DayOfWeek), then getting the session time and parsing it into a DateTime.

        Comment


          #5
          Thanks!

          Thanks for that MJT - much obliged. I think I will wait for the next release - cheers.

          Comment


            #6
            Session Begin and End Times no longer accessible

            A very recent post in this thread had mentioned that access to session data would be improved in Beta 5.

            However the only information I can find about this is in the e-mail notification of the availability of Beta 5: "Session information access has changed and the internal Begin/EndTime is no longer accessible".

            The "Code Breaking Changes" pdf is now outdated since it recommends using these. The SessionsOfDay page in the Ninjatrader help file is also outdated since the BeginDay, BeginTime, EndDay and EndTime are no longer defined.

            Is there a way to get around this? Thanks.

            Comment


              #7
              Due to issues raised about session template information being irrelevant as sole timestamps due to timezone shifts and daylight savings were addressed in B5. You guys now have to use the following to get :
              Code:
              Bars.Session.GetNextBeginEnd(DateTime time, out DateTime sessionBegin, out DateTime sessionEnd)
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                OK nice to this this finally working !

                The method name is quite misleading though : you don't get the NEXT begin/end, you get the CURRENTbegin/end (the begin/end of the session corresponding to the time you send as parameter).

                But it's a good choice : it's very useful to be able the determine begin and end of the session corresponding to a certain time.
                Last edited by gomifromparis; 12-01-2009, 06:31 PM.

                Comment


                  #9
                  Incorrect, you would get the NEXT begin/end it you where BEFORE a session.

                  Comment


                    #10
                    To clarify with examples.

                    Pass in a Saturday DateTime for a stock. Returns back Monday's session begin/end time.

                    Pass in a Monday DateTime for a stock. Returns back Monday's session begin/end time.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Ok I am stuck at the first exception

                      int sessionsBarsAgo = 0;

                      This means the current session amd the hour,min etc the session starts.

                      Code:
                      DateTime bar = new DateTime(Bars.GetSessionBar(sessionsBarsAgo).Time.Year, Bars.GetSessionBar(sessionsBarsAgo).Time.Month, Bars.GetSessionBar(sessionsBarsAgo).Time.Day, Bars.SessionBegin.Hour, Bars.SessionBegin.Minute, Bars.SessionBegin.Second);
                      BarsArray[int barSeries].Session.GetNextBeginEnd(DateTime time, out DateTime sessionBegin, out DateTime sessionEnd)

                      Bars.Session.GetNextBeginEnd(DateTime time, out DateTime sessionBegin, out DateTime sessionEnd)
                      I dont get it head in hands , how do i do the conversion to get session start for today?

                      Comment


                        #12
                        You would need to define two DateTime variables that would hold the SessionBegin and End time of the applied template, the 'out' paramters in the overload you posted. As relative time you pass just Time[0] in the get the relevant ones.

                        Comment


                          #13
                          Guys can you give a concrete example - it is very confusing .

                          I have the following 6.5 code what is the corresponding NT 7 syntax?

                          (ToTime(System.DateTime.Now) <= (ToTime (Bars.SessionBegin))

                          Comment


                            #14
                            mefTrader,

                            Please see the Help Guide article here for an example: http://www.ninjatrader.com/support/h...xtbeginend.htm

                            All you need to do is create two DateTime variables (sessionBegin and sessionEnd) then:
                            Code:
                            if (Bars.SessionBreak)
                                 Bars.Session.GetNextBeginEnd(Time[0], out sessionBegin, out sessionEnd);
                            Then you can use ToTime() on your sessionBegin variable.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              GetNextBeginEnd() Throwing Exceptions

                              I used

                              Bars.Session.GetNextBeginEnd(Bars.Get(0).Time, out firstSessionBegin, out firstSessionEnd);

                              in public override void Plot, and this caused the following exception:


                              "Error on plotting indicator 'Test'. Please check the 'OnBarUpdate' or the 'Plot' method: Der Index lag außerhalb des Bereichs. Er muss nicht negativ und kleiner als die Auflistung sein."

                              I transferred this to OnBarUpdate

                              if (CurrentBar == 0)
                              {
                              Bars.Session.GetNextBeginEnd(Time[
                              0], out firstBarSessionBegin, out firstBarSessionEnd);
                              }

                              and used the two variables in in public override void Plot, and it worked.

                              Where was my mistake?
                              Last edited by Harry; 05-27-2010, 05:36 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              599 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              344 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              558 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              557 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X