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 PaulMohn, Today, 05:00 AM
      0 responses
      8 views
      0 likes
      Last Post PaulMohn  
      Started by ZenCortexAuCost, Today, 04:24 AM
      0 responses
      6 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by ZenCortexAuCost, Today, 04:22 AM
      0 responses
      3 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by SantoshXX, Today, 03:09 AM
      0 responses
      16 views
      0 likes
      Last Post SantoshXX  
      Started by DanielTynera, Today, 01:14 AM
      0 responses
      5 views
      0 likes
      Last Post DanielTynera  
      Working...
      X