Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DataSeries on a secondary data series

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

    DataSeries on a secondary data series

    I am not sure that I am correctly initializing my DataSeries which I want to sync with my secondary data series. In Initialize() I'm doing:

    Code:
    Add(PeriodType.Minute,1);
    And in OnBarUpdate() I'm doing this just to see if I'm on the right track (and I'm not):

    Code:
    if (cumVol == null && BarsInProgress == 1)
    	cumVol = new DataSeries(this, MaximumBarsLookBack.Infinite);
    		
    if (cumVol != null && BarsInProgress == 1 && cumVol.ContainsValue(0))
    	Print("dataseries for bar " + CurrentBar + " is " + cumVol[0]);
    However I get the error:

    Code:
    Error on calling 'OnBarUpdate' method for indicator 'RelativeVolume' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    I looked at the thread:
    Note: In NinjaTrader 8 It is no longer needed to use an indicator to sync a secondary series. This can be done directly from the Series<T> (https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?seriest.htm) constructor. This post is left for historical purposes. Series objects are useful for


    But it showed the example of initializing the secondary DataSeries with an indicator, and I am wanting to manually fill in the values. I suspect my initialization is incorrect, but I don't have any other reference to go by.

    #2
    JoshDance, please go alongside the example provided for the sync - it would need to be an indicator as it implements an IDataSeries interface so you can provide the BarsArray to sync to.

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      JoshDance, please go alongside the example provided for the sync - it would need to be an indicator as it implements an IDataSeries interface so you can provide the BarsArray to sync to.
      And then do I manually go through the DataSeries when the indicator loads and in each OnBarUpdate() I can set my own values?

      Comment


        #4
        Correct, you can set your own values then in the correct BIP. What we discussed is just the initial sync.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Correct, you can set your own values then in the correct BIP. What we discussed is just the initial sync.
          Thanks Bertrand, got it working and indicator finished. Thanks for your help!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          574 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          332 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X