Announcement

Collapse
No announcement yet.

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 NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          71 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          143 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          76 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          47 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          51 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X