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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        45 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        14 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        20 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X