Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Charting Indicator Built from a Larger Data Series Onto a Smaller Data Series

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

    Charting Indicator Built from a Larger Data Series Onto a Smaller Data Series

    Hello,

    I am having an issue with getting indicators built from a larger data series to line up with a smaller data series on the chart.

    When using the chart tools there is no issue and it works as expected.

    But when I do nearly the same thing but through NinjaScript the indicators show up for only a few bars then stop. (As if they are scaled to the smaller data series instead of the larger?)


    Here is a snippet of the NinjaScript I am using to add the MACD/EMA to the chart.

    Code:
    else if (State == State.Configure)
    {
    
      AddDataSeries(BarsPeriodType.Minute, 240);
    
    }
    else if (State == State.DataLoaded)
    {
      macd = MACD(BarsArray[1],12,26,9);
      bigEMA = EMA(BarsArray[1], 14);
    
      macd.IsOverlay = false;
      AddChartIndicator(macd);
    
      bigEMA.IsOverlay = false;
      AddChartIndicator(bigEMA);
    }
    }

    Thank you to whoever takes the time to help me sort this out.

    #2
    Hi Morssel, thanks for posting.

    There is a note about this situation on the AddDataSeries documentation:

    "An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)"

    You can make a copy of the MACD and EMA indicator by opening it> right click the code> Save As> give it a new name. The copy of this strategy can be edited to add the extra series. Plot the data based on the secondary series then use AddChartIndicator to add this modified indicator. Note both the modified MACD, the EMA, and the strategy will all need to have the same call to AddDataSeries.

    Best regards,
    -ChrisL

    Comment


      #3
      Thanks for that information @NinjaTrader_ChrisL!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      630 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      564 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X