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

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
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks for that information @NinjaTrader_ChrisL!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by samish18, Today, 11:26 AM
      0 responses
      1 view
      0 likes
      Last Post samish18  
      Started by Trader146, 03-29-2024, 01:22 PM
      2 responses
      14 views
      0 likes
      Last Post Trader146  
      Started by tsantospinto, 04-12-2024, 07:04 PM
      7 responses
      126 views
      0 likes
      Last Post aligator  
      Started by futtrader, 04-21-2024, 01:50 AM
      5 responses
      56 views
      0 likes
      Last Post NinjaTrader_Eduardo  
      Started by PeakTry, Today, 10:49 AM
      0 responses
      2 views
      0 likes
      Last Post PeakTry
      by PeakTry
       
      Working...
      X