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

question on AddDataSeries() with barsToLoad argument

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

    question on AddDataSeries() with barsToLoad argument

    Firstly, my use case is:
    On a 1 minute chart with only 3 days data loaded,
    I would like to create an indicator based on daily bars. but I found that if I add data series with
    Code:
    AddDataSeries(Data.BarsPeriodType.Minute, 390;
    I loaded the indicator and found that the daily bars indicator doesn't work because too few days data is loaded.

    So I checked overload variances, and found bars to load overload
    Code:
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)
    But then I found this overload does not have period argument that I can define "390" minutes. so I'm confused...

    Could you advise what is use case of this overload, and how can I achieve my use case?

    #2
    Hello leontancfa,

    When using AddDataSeries(), its best to use 'Load data based on' to 'Days'. This will automatically load the same amount of days of days for the secondary series as the primary series. When using 'Load data based on' set to 'Bars', this will load the same number of bars, which will be a smaller amount of data for the added series. Loading 3 bars with day bars as the primary would load 3 1-minute bars for the secondary.

    With the overloads, the BarsPeriod is where you can set the bar type and interval.

    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)


    AddDataSeries("AAPL", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "US Equities RTH");
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks.
      What I wanted to do is to have primary series as 1 minute bar with only 3 days, because I don't want the chart be with too many bars;
      but my indicator based on daily bar with at least 90 days of data.

      It seems current overloads can't achieve this?

      Comment


        #4
        Hello leontancfa,

        The current overloads can achieve this.

        AddDataSeries(null, new BarsPeriod() { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, 4320, null, true);

        Where 4320 bars is 1440 minute bars in a day * 3 days.
        Last edited by NinjaTrader_ChelseaB; 10-19-2021, 09:02 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the example Chelsea!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          3 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          1 view
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          9 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Working...
          X