Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting Instrument RTH

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

    Getting Instrument RTH

    I'm trying to figure out how to get the Primary Instrument's Regular Trading Hours. I know I can call this code...

    Code:
    TradingHours th = Instrument.MasterInstrument.TradingHours;
    Session s = th.Sessions[0];
    And the s variable is an array that will contain Session details for each day of the week.

    I'm unclear on whether or not these details will always define the RTH. Also it's unclear whether or not these details factor in holidays or partial holidays.

    There has to be some sample code out there that demonstrates how to get an Instrument's RTH along with holidays factored for a given date without using a SessionIterator.

    Thoughts?

    #2
    Hello stoner,

    If the TradingHours template has hours defined for RTH hours then it will have RTH hours. If the TradingHours template has hours defined for ETH hours it will be ETH hours. If the TradingHours template is custom created using hours you have personally defined then it will use those custom hours.

    Holidays and partial holidays defined in the TradingHours template will not be included when returning the hours with the sessionIterator.




    To get a TradingHours template object by name use TradingHours.Get().
    An example of this is included with the BarsRequest page in the help guide.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      So the what I'm taking away here along with other threads I've view is it's Universally impossible to ever guarantee I'm getting RTH when using NT API. And I'll need to use a third party API to ensure I'm getting the actual RTH.

      I get the fact that the trading hours are defined in the Instrument template but it seems silly there's no simple means of getting the actual Instrument RTH for a given date.

      Comment


        #4
        Hello stoner,

        I can guaranteed that you can get a trading hours template by name... If trading hours template is setup for RTH hours it will be RTH hours.

        NinjaTrader uses TradingHours templates to define the hours for an instrument. A default TradingHours template will be assigned to the instrument in the instrument settings.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          But doesn't that require me to hard code that template name? I suppose that would be okay if I was using this indicator in US markets only but what do you do if you're looking at instruments in other global markets?

          Comment


            #6
            Hello stoner,

            No, TradingHours.Get(string instrumentName) uses a string and can be called anytime including in OnBarUpdate(). This means you can use a variable, array element, or input for the string. It does not have to be hard coded.

            But you do need to know what template you want to get. NinjaTrader can only tell you what has been set for the instrument in the instrument settings.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              That's the point I was trying to make. It's Universally impossible to ever guarantee I'm getting RTH on every NT system globally when using NT API because the default template could be defined with different time frames. And sure I could call TradingHours.Get(string instrumentName) but how do you know what template I want because NT doesn't have a static default RTH template for every instrument so I can fetch the actual RTH name as far as I can tell.

              It would be nice to have a API call like TradingHours.GetRTH(instrument, dateTime) or TradingHours.GetETH(instrument, dateTime) that actually return the time frames in the real world.

              Comment


                #8
                Hello stoner,

                Not all instruments have two sets of hours.

                You can also create an multi-dimensional array that holds a relationship of multiple tradinghours templates for an instrument..

                I am happy to submit a feature request for you.

                Are you wanting the ability for templates to be applied to instruments to be removed and replaced with multiple templates that are hard coded to an instrument so that we can force selecting ETH or RTH for that instrument without having to pull a template by name when it is not assigned to the instrument?

                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Ideally I'd like something similar to what I described, TradingHours.GetRTH(instrument, dateTime) or TradingHours.GetETH(instrument, dateTime).

                  The first would return the RTH Session information for a given instrument based on the date passed in. The session would provide the RTH open and close times of the date passed in.

                  The second would return the ETH Session information for a given instrument based on the date passed in. The session would provide the ETH open and close times of the date passed in. If there are no ETH for the instrument then the session returned would be null.

                  Make sense?

                  Comment


                    #10
                    Also, ideally that functionality should take holidays and partial holidays into consideration.

                    Comment


                      #11
                      Hello stoner,

                      Thank you for your suggestion.

                      I have created a feature request for you to have a TradingHours.GetRTH() method added. This request is being tracked under the number SFT-4570.

                      As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

                      Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

                      Please let us know if we may be of further assistance to you.

                      Comment


                        #12
                        Hey Kate,

                        Are there any updates on this, I couldn't find the command in the documentation.

                        Basically I have two bars and I want to do a check to see if they are both in the same RTH session.

                        Best,
                        Magnus

                        Comment


                          #13
                          Hello Magzor,

                          Thanks for your note.

                          This feature request has not yet been implemented on the NinjaTrader 8 platform. That said, I have added your vote to this feature request.

                          Deciding on features for future releases is not a simple black and white decision. There are many factors involved including but not limited to:
                          • Demand which is measured by objective user requests and subjective discretion on the part of our Product Management team.
                          • Feasibility
                          • Developer bandwidth
                          • Current projects in the queue
                          • Economics
                          You'll find a note regarding the feature request in the release notes section of the help guide when the feature is implemented.

                          Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

                          Let me know if I may assist further.​
                          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                          Comment


                            #14
                            Thanks for the reply Brandon.

                            And thanks for adding my vote to the feature request.

                            Do you have any good ideas how to check if a minute bar is within the daily RTH? I need the data feed itself to show all bars, but I only want trades to trigger within the normal trading hours. In this case I'm trading ES.

                            Comment


                              #15
                              Hello Magzor,

                              You can add a data series with AddDataSeries() using the RTH trading hours template, then with a sessionIterator you can get the start and end time of the session of the supplied added bars.

                              Compare the datetime of the bar to be greater than the session open and less than the session end.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              612 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              355 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
                              561 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              564 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X