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

It is not enough to declare a variable public - please update your documentation.

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

    It is not enough to declare a variable public - please update your documentation.

    A behavior described below may be expected, but it should be emphasized in a documentation. I'm working with user indicator ZigZagUTC , when the author declared several indicator variables as public:

    Code:
               public int dir;         // direction of current zigzag trend, 1=up, -1=down
                public int lasthibar;   // bar number of last swing high (bars ago = CurrentBar-lasthibar)
                public int lastlobar;   // bar number of last swing low
                public double lasthi;   // value of last swing high
    Somewhere in the indicator , dir value is set:

    Code:
                        if (hi[0] < hi[1]) dir = -1;
    and placing breakpoint using VS Express debugging I checked this code is accessed. However accessing dir outside of indicator :

    Code:
                    val1 = 
                        ZigZagUTC(BarsArray[BarsInProgress],
     0,zigSpan,useHiLo,Color.Transparent).dir;
    always gives 0 .

    Only adding a property :
    Code:
            [Browsable(false)]
            [XmlIgnore()]
            public int Dir1
            {
                // We need to call the Update() method to ensure our exposed variable is in up-to-date.
                get { Update(); return dir ; }
            }
    and accessing a property outside:
    Code:
                    val1 = 
                        ZigZagUTC(BarsArray[BarsInProgress], 0,zigSpan,
                        useHiLo,Color.Transparent).Dir1;
    solves the problem, it seems that any internal indicator state data may be accessed from outside only by means of property..

    #2
    xTrader1, correct this is expected and documented via a reference sample by us -



    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Well I know these examples, however the first shows using DataSeries, not an internal state value, the second shows how to use a property correctly, without emphasizing the property should be used, not just a public variable. So please emphasize this issue somewhere in the next release, may be under Tutorials/Indicators/Advanced. That's for others, I already know.

      Thank you,

      Comment


        #4
        I see thanks for clarifying, I will forward it - however if you check the calling strategy script, the public property of the indicator is clearly called to retrieve the kept up to date value.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        27 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 04-23-2024, 09:53 PM
        2 responses
        65 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        193 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,235 views
        0 likes
        Last Post xiinteractive  
        Working...
        X