Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetNextBeginEnd

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

    GetNextBeginEnd

    Hi,

    I am trying to iterate through all the historical data loaded when a strategy starts to get the beginning and ending date/times for each session. Is there a simple way to do this (starting from bar 0 going forward to Bars.Count - 1)?

    Alternatively if there is a way to iterate through the bars that would work as well.

    I just had a d'oh moment; I can start at the end and work backwards using Time[barsago].

    Best Regards,
    Scott
    Last edited by ScottB; 02-22-2012, 08:27 PM.

    #2
    Hello ScottB,
    Thanks for writing in and I am happy to assist you.

    To get the session start and end date please use Bars.Session.GetNextBeginEnd function.
    For more please refer here http://www.ninjatrader.com/support/h...xtbeginend.htm

    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Joydeep,

      I was able to do what I needed by using :

      bar = Bars.Get(sessionEndBar);

      I am not certain that is a documented feature or not but Bars.GetBar gave me an absolute bar number and the code I posted above then got me the time for that bar and then I could use GetNextBeginEnd as you suggested.

      Thanks,
      Scott

      Comment


        #4
        Bars.Get() documentation?

        How come I can't find anything on Bars.Get() ? Can you explain this function?

        Comment


          #5
          Hello funk101,
          Bars.Get() will return the IBar of the corresponding index. It is not documented and not officially supported.

          Please let me know if I can assist you any further.
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            funk, as Joydeep mentioned this is an undocumented feature. In this case all that really means is the NinjaTrader help does not include any information on it.

            If you have Visual Studio you can use the object browser to find many of these types of methods or the Intellisense in the editor will lead you to some. C#/.NET documentation will also help.

            It is very important to note that because these methods and properties are undocumented, NinjaTrader can change their meaning and behavior at at any time.

            When using undocumented features, only use those that NinjaTrader likely cannot change the behavior of without breaking their own internals and therefore are not very likely to change in future releases.

            Best Regards,
            Scott

            Comment


              #7
              Originally posted by NinjaTrader_Joydeep View Post
              To get the session start and end date please use Bars.Session.GetNextBeginEnd function.
              For more please refer here http://www.ninjatrader.com/support/h...xtbeginend.htm
              I have a related question. Say I have an indicator on a 24-hour session ES chart with 5 minute bars.

              Is there any way for my indicator code to identify the start and end bar, or start and end time, of the day session only, while running on a chart using 24-hour 5-minute intraday bars?

              I'm trying to develop such an indicator now. I can hard-code the day-session start and stop times, or make them input parameters, but this is impractical if I distribute my indicator to other traders in different time zones, who might be trading different markets. The chart needs to show 24-hour sessions, but the internals of the indicator requires information about the day-session part.

              -Alex

              Comment


                #8
                Hello anachronist,
                Bars.Session.GetNextBeginEnd will return the start and end time for that specific session only. It wont return you the day session.

                If you hard code the day session, then you may consider to use the TimeZoneInfo class to convert to local time http://msdn.microsoft.com/en-us/libr...ezoneinfo.aspx

                Please let me know if I can assist you any further.
                Last edited by NinjaTrader_Joydeep; 03-15-2012, 07:24 AM.
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  Someone supplied me with an indicator that uses both 24-hour and day sessions internally, and doesn't ask for session times in the parameters. I can't see the source code for it. Maybe it's using the timezone class with hard-coded session times, as you suggest. Thanks.
                  -Alex

                  Comment


                    #10
                    Hello anachronist,
                    This might be possible with unsupported NinjaScript methods, and you might like to take a look at this post http://www.ninjatrader.com/support/f...17&postcount=3

                    Please let me know if I can assist you any further.
                    JoydeepNinjaTrader Customer Service

                    Comment


                      #11
                      One such unsupported method appears to be Bars.GetTradingDayFromLocal(Time[0]). When it changes, a new trading day has begun.
                      -Alex

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      650 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      370 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      109 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      574 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      577 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X