Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

NT8 Equivalent of Bars.Session.GetNextBeginEnd()

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

    NT8 Equivalent of Bars.Session.GetNextBeginEnd()

    Hello,

    I'm in process of convert custom NT7 indicators to NT8.

    i'm see in beta of NT8, the convert of this are:

    Bars.SessionIterator....

    But Bars.SessionIterator seem not exist anymore on released verison fo NT8/

    How i'm can get the next session begin/end time ?

    #2
    Hello Twanaar,

    Thanks for the post.

    The Session iterator is its own class and does not belong to the Bars class. It does take a Bars object as a parameter.

    To get the next session begin and end times, use GetNextSession().

    The help guide has a good example of how to use this, it gets the next session and subsequently gets the begin/end time of the next session. GetNextSession() will return a boolean confirming if it was able to successfully calculate the next session. If it returns true you can use the methods available in the SessionIterator and all values returned will be relative to the next session.

    Please see the help guide page on SessionIterator and SessionIterator.GetNextSession()

    https://ninjatrader.com/support/help...oniterator.htm - SessionIterator main page, this page has the example you are looking for.

    https://ninjatrader.com/support/help...extsession.htm - GetNextSession()


    Please let us know if we may be of any further assistance.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello
      the links above don't work for me (page not found).

      how to change this script from nt7 to nt8?:
      if (Bars.IsFirstBarOfSession && BarsInProgress==Minute)
      {


      Bars.Session.GetNextBeginEnd(BarsArray[Minute], 0, out sessionBegin, out sessionEnd);
      timelastminutebarofday=ToTime(Times[Minute][CurrentBar - Bars.GetBar(sessionEnd)]);

      }

      this way you get historical at the beginning of each session the real last traded minute bar of the day, if the session end is different than what happened in reality. For example when there is a half day of trading the session end time will not be the time of the last minute bar of the day.

      tx

      Comment


        #4
        Hello yeshe,

        I tried both links and see that they are working. You can manually visit those links by opening the help guide and using the left side navigation. The first link is under NinjaScript -> Language Reference -> Common -> Session iterator. The second link is under the same section, you can click on the left side bar link for GetNextSession. There is a sample for both concepts on those pages.



        JesseNinjaTrader Customer Service

        Comment


          #5
          hello jesse,
          strange the links are still not working but i am able to go there in the way you described, and started coding according to the example (to get the current sessionend time):
          protected override void OnStateChange()
          {
          if (State == State.Historical)
          {
          sessionIterator = new SessionIterator(Bars);
          }​

          if (Bars.IsFirstBarOfSession )
          {
          sessionIterator.GetNextSession(Times[Minute], true);
          sessionEnd=sessionIterator.ActualSessionEnd;
          timelastminutebarofday=ToTime(Times[Minuut][CurrentBar - Bars.GetBar(sessionEnd)]);​
          }

          when compiling it gives errorcode cs0103 "the name "sessionIterator" does not exist in the current context. In the 3 lines of the code where sessionIterator is mentioned.
          Does the sessionIterator need to be declared first?


          Comment


            #6
            Hello yeshe,

            I would suggest to copy/paste the entire sample from the help guide. You have missed the private variable at the top of the sample.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            3 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            1 view
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            6 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            10 views
            0 likes
            Last Post bltdavid  
            Working...
            X