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

AddDataSeries - BarsToLoad under multi time-frame (same instrument)

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

    AddDataSeries - BarsToLoad under multi time-frame (same instrument)

    NT Team,

    Thank you for providing the AddDataSeries override barsToLoad.
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)
    Noting, AddDataSeries should ONLY be called during State.Configure, where the added DataSeries is the Primary DataSeries but different time-frame, this appears to present an issue. Specifically with the parameters instrumentName and trandingHoursName should NOT be accessed before State.DataLoaded.

    While instrumentName can be retrieved via Instrument.MasterInstrument.Name, the Instrument class should NOT be accessed before State.DataLoaded.

    While trandingHoursName can be retrieved via Bars.TradingHours.Name, the Bars object should NOT be accessed before State.DataLoaded.

    Am I missing something?

    While I believe both DaysToLoad and ApplyDefaultBasePeriodValue operate on the Primary Bars Object, can they be of help?

    Thanks
    Shannon

    #2
    Hello Shansen,

    Thank you for your post.

    AddDataSeries calls need to have the instruments hard coded, this means they would not access Instrument, Bars, or user input. For the overloads you are referencing here in the thread you would have to hard code each overload. For example:
    Code:
    AddDataSeries("AAPL", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, 60, "US Equities RTH", false);
    The AddDataSeries calls that can pick up the primary instrument are demonstrated below:
    Code:
    AddDataSeries(new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 });
    AddDataSeries(BarsPeriodType.Minute, 1);
    Please refer to the following link for more information: https://ninjatrader.com/support/help...nstruments.htm

    Please let me know if you have any questions.

    Comment


      #3
      Patrick,

      Similar to others (Multiple timeframe indicator and Understanding the new AddDataSeries constructor), I am attempting to increase the speed of calculation for a multi time-frame single instrument Strategy. Noting the Strategy is applied to different Instruments and thus hard-coding AddDataSeries instrumentName or tradingHoursName is not an option.

      I accept the currently allowed syntax for AddDataSeries on the Primary Instrument includes:
      - AddDataSeries(BarsPeriod barsPeriod)
      - AddDataSeries(BarsPeriodType periodType, int period)

      However, where a multi time-frame single instrument Strategy includes 5min bars, 60min bars, and requires 1000 bars to calibrate each DataSeries, this results in some 20,000 bars in the 5min BarsArray. Understandably, the calculation time blows out.

      Please advise how to calculate only the last 1000 historical bars before State.Realtime in any DataSeries.

      Alternatively, please develop something akin to:
      - AddDataSeries(BarsPeriodType periodType, int period, int barsToLoad)

      Comment


        #4
        Hello Shansen,

        Thank you for your response.

        I am assuming based on your reply that the chart or primary instrument needs to load more bars than the added series, is this correct?

        I look forward to your response.

        Comment


          #5
          Quite the opposite. Each BarsArray requires 1000 bars where:
          - BarsArray[0] = 5min
          - BarsArray[1] = 60min

          Comment


            #6
            Hello Shansen,

            Thank you for your response.

            If you are just adding the same instrument and changing the BarsPeriodType and Interval then it will adopt the same BarsToLoad as the primary instrument/bar series.

            So in your example let's say the BarsToLoad is set to 1000 on your chart, then you apply your indicator/strategy with the following line:
            Code:
            			else if (State == State.Configure)
            			{
            				AddDataSeries(BarsPeriodType.Minute, 60);
            			}
            The secondary (60 minute series) would load as many bars as the BarsToLoad, so 1000 in this case.

            Please let me know if you have any questions.

            Comment


              #7
              Patrick,

              Thank you for the clarification. In summary, where a Strategy is applied to a Chart where the DataSeries is based on 1000 Bars, BarsArray[1] (and subsequent BarsArrays) will also be based on 1000 Bars.

              Please advise how this can be achieved via the Control Center | Strategy Grid. While DaysToLoad exists, "BarsToLoad" does not appear to be an option.

              Again, thanks
              Shannon

              Comment


                #8
                Hello Shansen,

                Thank you for your response.

                You are correct on the detail for application to the chart. The Strategies tab does not have an option for BarsToLoad so in turn the same number of DaysToLoad is used for the added series when the strategy is added from the Strategies tab.

                Please let me know if you have any questions.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Shansen, 08-30-2019, 10:18 PM
                24 responses
                942 views
                0 likes
                Last Post spwizard  
                Started by Max238, Today, 01:28 AM
                0 responses
                9 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by rocketman7, Today, 01:00 AM
                0 responses
                4 views
                0 likes
                Last Post rocketman7  
                Started by wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                28 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 02-22-2024, 01:11 AM
                5 responses
                33 views
                0 likes
                Last Post wzgy0920  
                Working...
                X