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

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.
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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 geddyisodin, Today, 05:20 AM
          5 responses
          32 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by bmartz, Today, 09:30 AM
          2 responses
          12 views
          0 likes
          Last Post bltdavid  
          Started by f.saeidi, Today, 11:02 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by geotrades1, Today, 10:02 AM
          4 responses
          12 views
          0 likes
          Last Post geotrades1  
          Started by rajendrasubedi2023, Today, 09:50 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X