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

Secondary Data Series with Trading Hours stops Realtime updates

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

    Secondary Data Series with Trading Hours stops Realtime updates

    I'm trying to make an indicator which plots support and resistance on ETH and RTH data series.

    As advised on these forums I'm using 1440 minute bars to get RTH Day bars.

    However, if I add an RTH secondary data series to the indicator. All other Data series including the primary data series will not process Realtime updates unless the RTH session is in progress.

    I've attached a simple indicator which adds 1440 min RTH and 1 Day ETH secondary data series, and prints updates from OnBarUpdate.

    No realtime updates are made. I've set Update OnEachTick.

    Code:
     AddDataSeries(Instrument.FullName,
             new BarsPeriod() { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, 
                "CME US Index Futures RTH");
    
    AddDataSeries(Instrument.FullName,
            new BarsPeriod() { BarsPeriodType = BarsPeriodType.Day, Value = 1 },
                "CME US Index Futures ETH");

    Output:

    Code:
    Historical BarsInProgress:0 CurrentBar:994
    Historical BarsInProgress:0 CurrentBar:995
    Historical BarsInProgress:0 CurrentBar:996
    Historical BarsInProgress:0 CurrentBar:997
    Historical BarsInProgress:0 CurrentBar:998
    Historical BarsInProgress:0 CurrentBar:999
    Historical BarsInProgress:2 CurrentBar:99
    State Change:Transition
    State Change:Realtime
    The indicator can be found in Bugs/RealtimeBugTest
    Attached Files
    Last edited by frantic; 04-24-2018, 06:04 PM.

    #2
    Hello frantic,

    To confirm, the behavior you are expecting is that BarsInProgress 2 to print updates between the times of 5:00 PM eastern to 8:30 AM the next day and from 3:30 to 4:00 PM while BarsInProgress 1 is not processing.

    I am also able to reproduce this behavior and I have submitted a report to our development.

    Once I have a tracking ID for this behavior I will post in this thread.


    As a heads up, using the Instrument.FullName is not supported. The Instrument object of the primary series is not officially available until State.DataLoaded.

    (This will cause issues in different situations especially if this indicator is called from a strategy and the strategy is optimized)

    From the help guide:

    "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner."

    Below is a public link to the help guide.



    Another small note, you have chosen to use a 1 Day series as BarsInProgress 2.

    This means depending on your connection the daily bar will be pre-made by the provider and will not have the trading hours template applied.

    As an example if you are charting the ES 06-18 and you are connected to CQG/Continuum the day bar for BarsInProgress 2 will be CME US Index Futures ETH.


    Last, I did have to modify the script to run this.
    The using statements are to a namespace or class that was not provided.
    using NinjaTrader.Custom.ExtensionMethods;
    using NinjaTrader.Custom.MyProjects.Common;

    Exporting a script allows this to imported by another user.

    To export a NinjaTrader 8 NinjaScript do the following:
    1. Click Tools -> Export -> NinjaScript...
    2. Click the 'add' link -> check the box(es) for the script(s) you want to include
    3. Click the 'Export' button
    4. Enter a unique name for the file in the value for 'File name:'
    5. Choose a save location -> click Save
    6. Click OK to clear the export location message

    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>


    Below is a link to the help guide on Exporting NinjaScripts.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hey Chelsea, yes that is correct, not just BarsInProgress 2 though..... if I have the main data series as 5min ETH that stops working as well. The indicator processes no updates.

      Thanks for the extra info too.

      Comment


        #4
        Hello frantic,

        Thank you for your patience.

        Our Development team has let us know this behavior is expected as the Bar Series wait for the first intersecting bar before all Bar Series begin processing.

        Please let me know if you have any questions.

        Comment


          #5
          Ah ok, that's unfortunate. This difficulty of getting RTH Daily bar data is an absolute bugger.

          Is there anything you can suggest that could let me Plot the RTH Close, High and Low during the Globex trading session?

          My idea of adding a 1440 Minute Secondary time series seems to have hit a wall and I am out of ideas. I feel like it should be an easy thing to do but I'm totally stumped.

          Comment


            #6
            Hello frantic,

            Thank you for your response.

            You could use DateTime in the script and check Times of the Bars Series that uses the ETH and keep track of it's open at the time of the RTH open, it's close at the time of the RTH close, and then keep track of the highest high and lowest low between those times.

            I have attached an example of this to my response. Keep in mind to run the indicator example on an ETH bar series on the chart.

            Please let me know if you have any questions.
            Attached Files

            Comment


              #7
              would this help?

              Comment


                #8
                Patrick - thanks for the suggestion. That would definitely work; although my concern is that my timezone goes into and out of daylight-savings time 2 weeks before the USA. So there's always a 2 week period twice a year when the markets are opening an hour early or an hour late for me. This is part of the reason I wanted to use trading hours templates to keep me right.

                Ricam - thanks for the tip, looks promising, I will look into this.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by ETFVoyageur, Today, 07:55 PM
                0 responses
                6 views
                0 likes
                Last Post ETFVoyageur  
                Started by janio973, Today, 07:24 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by aligator, 01-06-2022, 12:14 PM
                4 responses
                242 views
                0 likes
                Last Post john_44573  
                Started by reynoldsn, Today, 05:56 PM
                0 responses
                13 views
                0 likes
                Last Post reynoldsn  
                Started by bortz, 11-06-2023, 08:04 AM
                51 responses
                1,996 views
                0 likes
                Last Post aligator  
                Working...
                X