Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Call an indicator inside another indicator

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

    Call an indicator inside another indicator

    I called an indicator(test) inside another indicator (test2). I found that test's OnBarUpdate was not called. Only test2's OnBarUpdate was called. I expected both OnBarUpdate should be called. Did I make a mistake?
    The scripts are attached here. Thank you.
    Attached Files

    #2
    Hello,

    Thanks for your post.

    A good reference would be to check the example in the help guide here: https://ninjatrader.com/support/help...alues_that.htm
    While the example is mainly about exposing a bool series, it also shows how to expose a variable.

    In test.cs, at the class level you could add: private int value = 10;

    Below the OnBarUpdate{} section you could add:

    #region properties

    public int TestValue
    {
    get { Update(); return value; } // put the private int value into public Test Value.
    }
    #endregion


    In test2.cs, just change myTest.value to myTest.TestValue.

    Comment


      #3
      Thank you for your help.

      I slightly modified the scripts. I did not call the update() for the variable value, but I added a Series<int> object in test.cs, OnBarUpdate was called. Does the Series<T> object trigger OnBarUpdate ?

      My scripts are attached here.
      Attached Files
      Last edited by stupiddove; 11-09-2021, 09:22 PM.

      Comment


        #4
        Hello,

        Thanks for your reply.

        Yes, the series would call the OnBarUpdate for the hosted script.

        We've recently updated the help guide to clarify "Hosted indicators will need to be accessed by the hosting script to ensure OnBarUpdate functionality. This can be done by: 1) Calling Update on the hosted indicator within the host script, 2) Including a plot in the hosted indicator and accessing the plot in the host script, 3) Including a plot in the hosted indicator and adding the indicator to the chart with AddChartIndicator (strategies only)" Reference: https://ninjatrader.com/support/help...nbarupdate.htm (Accessing the series would do the same as a plot in terms of the hosted script).

        Comment

        Latest Posts

        Collapse

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