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

Instrument RTH hours

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

    Instrument RTH hours

    Hi,

    Is there any way to determine, from code, the RTH hours for an instrument regardless of the template currently being used for the instrument?

    #2
    Hello Zeos6,

    You can get the hours for a trading hours template. But if the template is not assigned to the instrument, then you will need to know the name of the template you want the hours from.

    Below is a link to the help guide on the TradingHours.Sessions.


    The Instrument.MasterInstrument.TradingHours has the template assigned to the instrument.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea B,

      Thank you for the reference and the quick reply. The reference you provided is somewhat helpful but not entirely. It is based on a session idx; i.e. Bars.TradingHours.Sessions[0].TradingDay.

      More specifically, I'd like to know:
      1. How can I retrieve the Trading hours (Session) template currently used by the instrument.
      2. How can I retrieve a specific template by name, for example the trading hours for the CME US Index Futures RTH session template.

      Thank you for your help.

      Comment


        #4
        Hello Zeos6,

        Are you finding the Instrument.MasterInstrument.TradingHours I have suggested in my previous post is not returning the trading hours of the instrument?

        As far as getting a template by name, use TradingHours.Get(string templateName).

        The help guide has this on the BarsRequest page.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Good morning Chelsea B,

          Thank you for your reply. It was helpful and I was able to retrieve the information.
          One issue did come up though. Many of the Trading Hours templates in NT8 are specified in terms of Central Time. Is there a way to correct the output received from the inquiry, for example the BeginTime, for the actual time zone I am in (Eastern, UTC-05) without changing the templates? Thank you.

          Also, is there a way to retrieve via code the time zone that the BeginTime, for example, is referenced to?
          Last edited by Zeos6; 11-21-2019, 10:21 AM. Reason: Additional clarification:

          Comment


            #6
            Hello Zeos6,

            The time zone is in the TimeZoneInfo information.


            You would need to use custom C# code to convert to other time zones.
            Below is a public link to the microsoft documentation.
            Learn to convert times between from one time zone to another in .NET. Also learn to convert DateTimeOffset values that have limited time zone awareness.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Great stuff! Thank you for your help Chelsea B.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by PaulMohn, Today, 12:36 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by yertle, Yesterday, 08:38 AM
              8 responses
              36 views
              0 likes
              Last Post ryjoga
              by ryjoga
               
              Started by rdtdale, Today, 01:02 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by alifarahani, Today, 09:40 AM
              3 responses
              16 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by RookieTrader, Today, 09:37 AM
              4 responses
              19 views
              0 likes
              Last Post RookieTrader  
              Working...
              X