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

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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        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.
            JesseNinjaTrader Customer Service

            Comment


              #7
              ok thanks for your assistance

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ageeholdings, Today, 07:43 AM
              0 responses
              7 views
              0 likes
              Last Post ageeholdings  
              Started by pibrew, Today, 06:37 AM
              0 responses
              4 views
              0 likes
              Last Post pibrew
              by pibrew
               
              Started by rbeckmann05, Yesterday, 06:48 PM
              1 response
              14 views
              0 likes
              Last Post bltdavid  
              Started by llanqui, Today, 03:53 AM
              0 responses
              6 views
              0 likes
              Last Post llanqui
              by llanqui
               
              Started by burtoninlondon, Today, 12:38 AM
              0 responses
              12 views
              0 likes
              Last Post burtoninlondon  
              Working...
              X