Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Access Parent Indicator Property Values from Nested Indicator

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

    Access Parent Indicator Property Values from Nested Indicator

    I am trying to acces property values of a parent indicator from the nested indicator but cannot.
    I have tried adding parent indicator as parameter when calling the nested indicator however the parent indicator property reference within the nested indicator is always null.
    How can I access parent Indicator values from nested?
    Thank you


    ---parent indi script---

    State = State.Configure
    nestedIndicator = NestedIndicator(this)

    OnBarUpdate
    {
    nestedIndicator.Update();
    }​

    ----------------------------


    ---nested indi script---

    [xmlIgnore]
    [NinjaScriptProperty]
    public Indicator parentIndi {get; set;}

    OnBarUpdate
    {
    if( parentIndi == null ) Print("parent is null");
    }
    -------------------------------

    #2
    Hello b16_aln,

    The correct way to do that would be to create a public property in the child indicator for each value that you wanted to know about so it can be passed to the child indicator when calling it. For example the SMA has the int Period input which is required when calling the indicator, it would be the same process for any parameter that the child indicator should need. Rather than passing the parent indicator you would pass the values themselves as parameters.

    OnBarUpdate
    {
    nestedIndicator(parameter1,parameter2).Update();

    }​
    Last edited by NinjaTrader_Jesse; 03-22-2024, 09:11 AM.

    Comment


      #3
      thanks Jesse, why can I not pass the whole indicator object which holds all the values? I shoudl be able to set a public indicator object in the nested indicator and pass the parent to access all the values, why can i not?

      Comment


        #4
        Hello b16_aln,

        Depending on the values you need that wouldn't make sense because the child indicator is not going to be able to call the parent indicator to update the values and have its OnBarUpdate process.

        Comment


          #5
          The values of the indi parameter would get updated in the same way that the values of parameter of indi.variable would, I see no difference. The child wouldn;t need to call the parent as the parameter is passed as reference no?

          Comment


            #6
            Hello b16_aln,

            All that I can suggest for this would be to pass the values similar to how you would in the SMA indicator and make a public user input for the values you need and then call the indicator from OnBarUpdate if they need to be updated later.

            Comment


              #7
              ok thanks for your assistance

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              600 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              347 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
              558 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              558 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X