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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        576 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X