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

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

    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.
          Emily C.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Aviram Y, Today, 05:29 AM
          0 responses
          2 views
          0 likes
          Last Post Aviram Y  
          Started by quantismo, 04-17-2024, 05:13 PM
          3 responses
          25 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          7 responses
          34 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cls71, Today, 04:45 AM
          0 responses
          6 views
          0 likes
          Last Post cls71
          by cls71
           
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          217 views
          1 like
          Last Post PaulMohn  
          Working...
          X