Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DataSeries input to indicator in strategy Initialize() routine

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

    DataSeries input to indicator in strategy Initialize() routine

    Why doesn't the 'Add(SMA(MyDataSeries,10))' statement work as expected? Documentation says all indicator methods accept DataSeries type as input, but here, NT substitutes the Close for MyDataSeries. Note that the 'Print(SMA(MyDataSeries,10)[0])' statement works as expected and prints the 10 period SMA of MyDataSeries. I would like to plot this as well, which is why I put in the Add() statement in the Initialize routine.


    public class MyStrategy : Strategy {
    ...
    private DataSeries MyDataSeries;
    ...
    protected override void Initialize() {
    ...
    MyDataSeries = new DataSeries(this);
    Add(SMA(MyDataSeries, 10));
    ...
    }

    protected override void OnBarUpdate() {
    ...
    MyDataSeries.Set(somevalue);
    Print(SMA(MyDataSeries,10)[0]);
    ...
    }
    }

    #2
    trader, thank you for the inquiry.

    I'll have to consult with a coworker about this question and get back to you tomorrow. Thank you for understanding.
    AustinNinjaTrader Customer Service

    Comment


      #3
      trader20, the Add() method in the Initialize() for strategies is used to display NinjaTrader indicators for visual confirmation - http://www.ninjatrader-support2.com/...ead.php?t=3228

      You custom dataseries values would not be set until the OnBarUpdate() is processed, so for this to display as you would expect, please use this reference sample for how to plot in realtime from a strategy - http://www.ninjatrader-support2.com/...ead.php?t=6651

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      647 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X