Announcement

Collapse
No announcement yet.

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 -



    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X