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 sjsj2732, Yesterday, 04:31 AM
        0 responses
        27 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        283 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        280 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        131 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        90 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X