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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      60 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      147 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      161 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      97 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      284 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X