Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Instrument and Indicator on Indicator in a Strategy

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

    Multi Instrument and Indicator on Indicator in a Strategy

    Hi Ninja Team,

    I'm trying to add an indicator to a strategy chart that uses the second data series (BarsArray[1]) as an input, and then trying to add an indicator that uses THAT indicator as an input. Here is an example:

    PHP Code:
    // Variables
     
    private string myInstrument = @"SPY"; 
     
    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    Add(myInstrument,BarsPeriod.Id, BarsPeriod.Value);//Adds another bar series to the strategy... BarsArray[1]
     
    //This Complies, but throws an error 'BarsArray property can not be accessed from within 'Initialize' method 
    Add(SMA(BarsArray[1], 14));//Adds an SMA plot to the chart from BarsArray[1] instrument
     
    //This is not OK
    //Add(SMA((myInstrument,BarsPeriod.Id, BarsPeriod.Value), 14));
     
    //This is not OK
    //Add (SMA(myInstrument, 14));
     
    //Indicator on Indicator. This compiles, but throws the error
    //Add (EMA((SMA(BarsArray[1], 14)), 14));
     
     
    }
     
     
    protected override void OnBarUpdate()
    {
    //Do something
    } 
    
    What's the best way for me to accomplish this? Thanks.

    #2
    MXASJ,

    BarsArray does not exist in Initialize(). You will want to use StrategyPlot techniques to achieve what you want.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    601 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    347 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    559 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    558 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X