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

assigning trading hours within OnStateChange

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

    assigning trading hours within OnStateChange

    Hi,

    Is it possible to assign (re-assign) or change the Trading Hours within OnStateChange for the primary data series?

    E.g. suppose I have a strategy that I am running on ZS and ES, where for ZS I want to use say CBOT Agriculturals ETH, while for ES I want to use CME US Index Futures ETH.

    Can I do something with in OnStateChange like this: if instrument.MasterInstrument.name contains ZS then use CBOT Agriculturals ETH, else if instrument.MasterInstrument.name name contains ES than use CME US Index Futures ETH ?


    #2
    Hello uday12,

    Thanks for your post.

    When you assign a strategy to a chart, the strategy will use the Trading hours of the charts data series. When you apply it to the ES (assuming default trading hours used) then the strategy will use the CME US Index Futures ETH as that is the default for the ES. When you the strategy to ZS, it will use the default trading hours of CBOT Agricultural ETH as that is the instruments default trading hours.

    In the case of a strategy that has both data series, the strategy would use the primary data series trading hours (which cannot be changed by the strategy), however when you add the second data series you can specify in the AddDataSeries() method which trading hours to use for that data series. reference: https://ninjatrader.com/support/help...dataseries.htm

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,
      Do I understand correctly that the trading hours template for the secondary data series needs to be specified within the script? - So it uses the default trading hours template for the specific instrument irrespective of the chart template?

      Comment


        #4
        Hello Balage0922,

        Thanks for your post.

        An added data series will use the same trading hours as the primary instrument (unless the AddDataseries() has specified a different trading hours template). For example if you create a chart of NQ 03-20 and select CME US Index futures RTH then in your script add a data series of ES 03-20 and then add a print statement in OnBarUpdate() that shows the BarsInProgress and time of the bar, you would see that both series start/end on RTH hour even though the default for ES would be ETH.

        "Do I understand correctly that the trading hours template for the secondary data series needs to be specified within the script? " Yes if you want to use different trading hours than the primary instrument.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by gravdigaz6, Today, 11:40 PM
        0 responses
        4 views
        0 likes
        Last Post gravdigaz6  
        Started by MarianApalaghiei, Today, 10:49 PM
        3 responses
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by XXtrader, Today, 11:30 PM
        0 responses
        3 views
        0 likes
        Last Post XXtrader  
        Started by love2code2trade, Yesterday, 01:45 PM
        4 responses
        28 views
        0 likes
        Last Post love2code2trade  
        Started by funk10101, Today, 09:43 PM
        0 responses
        9 views
        0 likes
        Last Post funk10101  
        Working...
        X