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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    177 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    332 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    254 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    356 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    184 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X