• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 Knortzsch, Today, 05:26 AM
        0 responses
        1 view
        0 likes
        Last Post Knortzsch  
        Started by aitropap, Today, 05:19 AM
        0 responses
        1 view
        0 likes
        Last Post aitropap  
        Started by Herrwolf1, Today, 05:11 AM
        0 responses
        4 views
        0 likes
        Last Post Herrwolf1  
        Started by authenticx, Yesterday, 03:51 PM
        1 response
        29 views
        0 likes
        Last Post NT-Roland  
        Started by hattieaguilar, Today, 02:58 AM
        0 responses
        5 views
        0 likes
        Last Post hattieaguilar  
        Working...
        X