Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Series<double> for secondary data series?

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

    Series<double> for secondary data series?

    Hi,
    I have a secondary data series in my indicator and I want to create a Series<double> which stores information for this secondary series rather than the primary data series.
    I am declaring the series as:

    private Series<double> numberSeries;

    I create the series in State.DataLoaded:

    numberSeries = new Series<double>(this, Period <= 256 ? MaximumBarsLookBack.TwoHundredFiftySix : MaximumBarsLookBack.Infinite);


    I then create the secondary data using AddDataSeries

    So my question is how can I access the numberSeries so that [0] element is the value for the current secondary bar and [1] element is the previous element etc... for the secondary data series?

    It's all working except that when I access element [1] of numberSeries it's accessing the data corresponding for the previous bar of the primary data series rather than the previous bar of the secondary series.

    Regards,
    iq
    Last edited by iq200; 10-21-2019, 06:27 AM.

    #2
    Hello iq200,

    Thanks for your post.

    A Series object can be synced to a NinjaScriptBase (using "this") or by specifying the Bars object to be synchronized with. For example:

    mySeries = new Series<double>(BarsArray[1], MaximumBarsLookBack.Infinite);

    Documentation for Series<T> can be found here - https://ninjatrader.com/support/help...8/?seriest.htm

    I look forward to being of further assistance.

    Comment


      #3
      Hi Jim,
      Many thanks for getting back.
      Funnily enough I was going to post that I had just found out the information on your help pages:



      I was in the process of testing it out
      KInd Regards,
      iq

      Comment


        #4
        Originally posted by NinjaTrader_Jim View Post
        Hello iq200,

        Thanks for your post.

        A Series object can be synced to a NinjaScriptBase (using "this") or by specifying the Bars object to be synchronized with. For example:

        mySeries = new Series<double>(BarsArray[1], MaximumBarsLookBack.Infinite);

        Documentation for Series<T> can be found here - https://ninjatrader.com/support/help...8/?seriest.htm

        I look forward to being of further assistance.
        Hi Jim,
        When it's synchronized, does that mean I don't need to manually sync mySeries[0] with Closes[1][0] in OnBarUpdate? Can you confirm that the data in mySeries is automatically synced with BarsArray[1]?
        Last edited by affilife; 02-16-2024, 04:17 PM.

        Comment


          #5
          Originally posted by affilife View Post

          Hi Jim,
          When it's synchronized, does that mean I don't need to manually sync mySeries[0] with Closes[1][0] in OnBarUpdate? Can you confirm that the data in mySeries is automatically synced with BarsArray[1]?
          If you do not specify the bars object, the series will sync with the primary data series, which is BarsArray[0]. If you want a custom series to be in sync with an added bars object, you must use one of the overloads that allows an argument for the bars. The available constructors are listed and explained on this page:


          Please let us know if we may be of further assistance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          590 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          342 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          555 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          552 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X