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

Exposing Complex Indicator Values

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

    Exposing Complex Indicator Values

    I know that it is possible to expose simple value types or series objects but is it possible to expose a complex indicator value, for example a class, struct, or tuple? If yes, can you provide a code sample/ Thank you.

    #2
    Hello Zeos6,

    Thanks for the inquiry.

    I'll see what I can come up with.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you very much Jim. Much appreciated.

      Comment


        #4
        Hello Zeos6,

        I have the requested sample attached.

        The general gist for exposing a variable/class/struct and accessing it externally is to create a public instance of that variable/class/struct.

        Please keep in mind that while we support our product, providing educational samples to demonstrate C# concepts begins to exceed the scope of support that we may offer. As these concepts can get more and more complex, our ability to answer client inquiries on the platform becomes increasingly difficult.

        If there is anything else I can do to assist, please let me know.
        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Thank you Jim. I do understand and very much appreciate this.

          Normally, when simple value types are exposed for sharing, an Update() is used. This is not done in the sample you provided. How can one ensure that the shared complex entities are at their most current values?
          Last edited by Zeos6; 09-13-2017, 10:08 AM.

          Comment


            #6
            Hello Zeos6,

            Since I could not place a getter directly within the public class, I made sure to call SampleSharedClassesAndStructs().Update(); from the Strategy that calls it.

            You could move the Update() call to a getter for the declaration of the public SharedClass and also create private SharedClass that can act as the return value for the getter of the public class.

            For example:
            Code:
            private SharedClass myClass;
            public SharedClass	MyClass{get { Update(); return myClass; } set{myClass = value;} }
            This would not be possible for structs and would be redundant since a struct is a Value Type and would return a new copy of the value.

            If there is anything else I can do to be of further help, please let me know.
            JimNinjaTrader Customer Service

            Comment


              #7
              Got it. Thank you very much for the clarification Jim. Appreciate your help.

              Comment


                #8
                I just found this interesting thread!

                So to sum up:

                If a Struct is exposed, then there is no need to call the Update()

                But if it is a Tuple, or a List that are exposed then the Update() should be called. Is that correct?

                Comment


                  #9
                  Hello roblogic,

                  Update() should be used to ensure properties are up to date when the hosting script accesses those properties. Best practice would be to include Update() in the getter of that public property, but this cannot be done for all of these types. Series objects would not need the Update call added to the getter, but other properties would. If the property cannot have Update applied in the getter, than the next best option is to call Indicator.Update() in the hosting script as done in line 63 of SampleSharedClassesAndStructsStrategy.

                  We look forward to assisting.
                  JimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by selu72, Today, 02:01 PM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Zachary  
                  Started by WHICKED, Today, 02:02 PM
                  2 responses
                  11 views
                  0 likes
                  Last Post WHICKED
                  by WHICKED
                   
                  Started by f.saeidi, Today, 12:14 PM
                  8 responses
                  21 views
                  0 likes
                  Last Post f.saeidi  
                  Started by Mikey_, 03-23-2024, 05:59 PM
                  3 responses
                  51 views
                  0 likes
                  Last Post Sam2515
                  by Sam2515
                   
                  Started by Russ Moreland, Today, 12:54 PM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Working...
                  X