Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting an indicator from a secondary data series

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

    Plotting an indicator from a secondary data series

    I am developing a multi-time-frame strategy with 2 time frames and I want to plot indicators on each time frame - an EMA on the primary data series and a price action swing oscillator on the secondary data series in a second panel.
    My problem is that Add (to add the indicator for plotting) can only be used in Initialize(), but I can't use BarsArray[1] in Initialize() because the bars objects don't exist yet. So how do I plot the indicator from the secondary data series? In other words this is what I would like to be able to do, but can't:
    HTML Code:
            protected override void Initialize()
            {
                CalculateOnBarClose = true;
    
                ema = EMA( EMAperiod );
                ema.Plots[0].Pen.Color = EMAcolor;
                ema.Plots[0].Pen.Width = EMAlineWidth;
                Add( ema );
                
                Add (PeriodType.Minute, filterPeriod);
                paso = PriceActionSwingOscillator(BarsArray[1], dtbStrength, swingSize, swingType, useCloseValues);
                paso.Panel = 2;
                Add(paso);
            }

    #2
    Hello,
    You would not be able to have an indicator plot off of BarsArray[1] natively from a strategy. You would need to create an indicator that plots off of the secondary data series and then call that indicator in your strategy.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Is there an example of an existing indicator that does that, so that I can see how it is done?
      Thanks.

      Comment


        #4
        Hello,
        I have created an example and attached this of how you could do this.
        Please let me know if you have any questions on the example.
        Attached Files
        Cody B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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