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

Is an Array of Series possible?

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

    Is an Array of Series possible?

    I use series in my indicator defined as below:

    private Series<double> myDoubleSeries;

    However I need to create 30 different series. Is it possible to create an array of Series?

    basically would become a 2 dimensional array.

    #2
    Hello afshinmoshrefi, and thank you for your question. While this is definitely possible in C#, you will need to be careful to ensure that every single series is instantiated. The easiest way to do this is to set it up in a loop, like so :

    Code:
    private List<Series<double>> myArrayOfDoubleSeries = new List<Series<double>>();
    for (int i = 0; i < 30; i++)
    {
        myArrayOfDoubleSeries.Add(new Series<double>(this));
    }
    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      This worked. Thanks. How can I expose this List of Series to be accessible from another indicator?

      Comment


        #4
        If we change private to public in the above code sample we should be all set.

        Code:
        [FONT=Courier New]public List<Series<double>> myArrayOfDoubleSeries = new List<Series<double>>();
        for (int i = 0; i < 30; i++)
        {
            myArrayOfDoubleSeries.Add(new Series<double>(this));
        }[/FONT]
        It is probably easiest to call every member in a foreach loop from your outer indicator or strategy, that is,

        Code:
        [FONT=Courier New]int i = 0;
        foreach(Series<double> example in myIndicator.myArrayOfDoubleSeries)
        {
            Print("the 0th value of series " + i++ + " is " + example[0]);
        }[/FONT]
        If you just need one series in particular, you can do this :

        Code:
        [FONT=Courier New]Print("The 0th value of series 2 is" + myIndicator.myArrayOfDoubleSeries[2][0]);[/FONT]
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          array of dataseries in NT7



          NT8 would be similar, with appropriate syntax updates.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          39 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Today, 08:51 AM
          2 responses
          15 views
          0 likes
          Last Post bill2023  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          167 responses
          2,260 views
          0 likes
          Last Post jeronymite  
          Started by warreng86, 11-10-2020, 02:04 PM
          7 responses
          1,362 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Perr0Grande, Today, 08:16 PM
          0 responses
          5 views
          0 likes
          Last Post Perr0Grande  
          Working...
          X