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 CortexZenUSA, Today, 12:53 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by usazencortex, Today, 12:43 AM
        0 responses
        5 views
        0 likes
        Last Post usazencortex  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        168 responses
        2,265 views
        0 likes
        Last Post sidlercom80  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X