Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Named DataSeries

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

    Named DataSeries

    Is there a way to assign friendly names to data series added using AddDataSeries. I have over 10 data series I need to add to an indicator and using friendly names would make the code easier to read and less likely to have an error introduced. I know the following will work, but it seems like overkill just to get friendly names.

    Code:
    protected override void OnStateChange()
    {
       .
       .
       .
       else if (State == State.Configure)
       {
          AddDataSeries("AUDUSD", BarsPeriodType.Minute, 1);
          AddDataSeries("USDJPY", BarsPeriodType.Minute, 1);
       }
       else if (State == State.DataLoaded)
       {
          audusd = new Series<double>((BarsArray[1]);
          audjpy = new Series<double>((BarsArray[2]);
       }
    }
    
    protected override void OnBarUpdate()
    {
       if (BarsInProgress == 0)
       {
          // do normal stuff
       }
       else if (BarsInProgress == 1) audusd[0] = Closes[1][0];
       else if (BarsInProgress == 2) audjpy[0] = Closes[2][0];
    }
    Thanks,
    Greg
    The Trading Mantis
    NinjaTrader Ecosystem Vendor - The Trading Mantis

    #2
    Hi Greg, thanks for posting.

    You can make a public property that returns the Closes[1] array:
    Code:
    else if (State == State.Configure)
    {
        AddDataSeries("MSFT");
    }
    ...
    protected override void OnBarUpdate()
    {
    if(BarsInProgress == 1)
        {
            Print(MySecondCloseSeries[0]);
        }
    }
    
    [Browsable(false)]
    [XmlIgnore]
    public PriceSeries MySecondCloseSeries
    {
        get { return Closes[1]; }
    }
    Best regards,
    -ChrisL

    Comment


      #3
      That was exactly what I was looking for! Thanks Chris!
      The Trading Mantis
      NinjaTrader Ecosystem Vendor - The Trading Mantis

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      607 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      353 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      560 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      561 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X