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 helpwanted, Today, 03:06 AM
          1 response
          5 views
          0 likes
          Last Post sarafuenonly123  
          Started by Brevo, Today, 01:45 AM
          0 responses
          7 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by aussugardefender, Today, 01:07 AM
          0 responses
          5 views
          0 likes
          Last Post aussugardefender  
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          242 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          9 responses
          384 views
          1 like
          Last Post Gavini
          by Gavini
           
          Working...
          X