Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Two multi-timeframe hosted indicators doesn't showing in chart (Strategy)

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

    Two multi-timeframe hosted indicators doesn't showing in chart (Strategy)

    Hi!

    I can't see in the chart a second hosted indicator with second series input. Just I see the indicator but with primary data series besides is declarated with second data series.

    I'm on two minutes chart.
    ---------------------------------------------------------------------------------

    public class test : Strategy
    {

    private SMA sma50;
    private SMA sma50_2;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {​
    ....
    }
    else if (State == State.Configure)
    {​

    AddDataSeries(BarsPeriodType.Minute, 15);


    sma50 = SMA(Close, 50);
    sma50.Plots[0].Brush = Brushes.White;​

    sma50_2 = SMA(Closes[1], 50);
    sma50_2.Plots[0].Brush = Brushes.Yellow;​

    }
    else if (State == State.DataLoaded)
    {​
    AddChartIndicator(sma50);
    AddChartIndicator(sma50_2);
    }​


    protected override void OnBarUpdate()
    {​
    ....
    }
    }

    #2
    Hello franjcy,

    Thanks for your post.

    The code you shared adds a secondary 15-minute data series to the script to use for calculations.

    The sma50_2 indicator is an SMA indicator set to use the Close series of the added secondary series for its calculation.

    Note that AddDataSeries() adds a secondary series to use for calculations within the script. The secondary series will NOT be visible on the Chart window when enabling the strategy on the Chart. There are no means available for having the secondary series be displayed on the chart when the strategy is enabled on the chart.

    See this help guide page for more information about AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm

    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello franjcy,

      Thanks for your post.

      The code you shared adds a secondary 15-minute data series to the script to use for calculations.

      The sma50_2 indicator is an SMA indicator set to use the Close series of the added secondary series for its calculation.

      Note that AddDataSeries() adds a secondary series to use for calculations within the script. The secondary series will NOT be visible on the Chart window when enabling the strategy on the Chart. There are no means available for having the secondary series be displayed on the chart when the strategy is enabled on the chart.

      See this help guide page for more information about AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm
      I read it but I still have doubts.

      You said "The sma50_2 indicator is an SMA indicator set to use the Close series of the added secondary series for its calculation." but when I print "sma50[0] and "sma50_2[0]" they print the same output.

      As well I read the hosted indicator has to be the same "AddDataSeries()" inside her code. So, Would I have to modify the source font of the original SMA if i want to use the 2 SMAs ?
      Last edited by franjcy; 02-12-2024, 10:04 AM.

      Comment


        #4
        Hello franjcy,

        Thanks for your notes.

        When testing this on my end I am seeing different values print to the NinjaScript Output window for the SMA calculating from the primary series and the SMA calculating from the secondary series.

        See the attached screenshot.

        I have also attached the test script used to test this so you may try it on your end.

        "As well I read the hosted indicator has to be the same "AddDataSeries()" inside her code."

        No, you do not need to modify the SMA indicators code to also call AddDataSeries().

        "Should your script be the host for other scripts that are creating indicators and series dependent resources in State.DataLoaded, please make sure that the host is doing the same AddDataSeries() calls as those hosted scripts would. For further reference, please also review the 2nd example below and the 'Adding additional Bars Objects to NinjaScript' section in Multi-Time Frame & Instruments​"

        This note from the AddDataSeries() help guide indicates that if the indicator script calls AddDataSeries() and a custom NinjaScript strategy is the host for the indicator, you must call the same AddDataSeries() call in the strategy that the indicator is using.

        For example, if an indicator calls AddDataSeries() to add a 15-minute secondary series and you use the indicator in a NinjaScript strategy, that NinjaScript strategy also needs to call AddDataSeries() to add a 15-minute secondary series.

        AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm
        Attached Files
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          Hello franjcy,

          Thanks for your notes.

          When testing this on my end I am seeing different values print to the NinjaScript Output window for the SMA calculating from the primary series and the SMA calculating from the secondary series.

          See the attached screenshot.

          I have also attached the test script used to test this so you may try it on your end.

          "As well I read the hosted indicator has to be the same "AddDataSeries()" inside her code."

          No, you do not need to modify the SMA indicators code to also call AddDataSeries().

          "Should your script be the host for other scripts that are creating indicators and series dependent resources in State.DataLoaded, please make sure that the host is doing the same AddDataSeries() calls as those hosted scripts would. For further reference, please also review the 2nd example below and the 'Adding additional Bars Objects to NinjaScript' section in Multi-Time Frame & Instruments​"

          This note from the AddDataSeries() help guide indicates that if the indicator script calls AddDataSeries() and a custom NinjaScript strategy is the host for the indicator, you must call the same AddDataSeries() call in the strategy that the indicator is using.

          For example, if an indicator calls AddDataSeries() to add a 15-minute secondary series and you use the indicator in a NinjaScript strategy, that NinjaScript strategy also needs to call AddDataSeries() to add a 15-minute secondary series.

          AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm
          Thanks Brandon for your reply.

          Thanks to your example i saw my error: I'd putted the assignment of EMAs inside " (State == State.Configure)" so when i putted on DataLoaded it prints different values.

          Also I understood about hosted indicators and multi time series.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          595 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          554 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X