Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Belfortbucks, Today, 09:29 PM
        0 responses
        6 views
        0 likes
        Last Post Belfortbucks  
        Started by zstheorist, Today, 07:52 PM
        0 responses
        7 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        151 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        6 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Working...
        X