Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Variables.

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

    Variables.

    Please ,is there a means of checking bar by bar ticks on trend.if so, the syntax used.

    I will also like a method of reset for trend bars thank you

    #2
    Hello Emma1,

    Thanks for your post.

    I'm sorry but I do not understand what you are asking for.

    Can you explain further or perhaps add a screenshot of what you are trying to accomplish?

    Comment


      #3
      how do i set a reset for for high and low bars in Trend.

      Comment


        #4
        Hello Emma1,

        Thanks for your reply.

        The words "set" and "reset" could be applied to an integer based counter or could be applied to a bool variable.

        for example, in pseudo code:

        if (condition to determine a trend is true)
        {
        myTrend = true; // set a bool variable called myTrend to true
        }
        else
        {
        myTrend = false; // reset bool when no longer a trend
        myHighCounter = 0; // reset integer high bar counter variable to zero for next trend
        myLowCounter = 0; // reset integer low bar counter variable to zero for next trend
        }

        if (myTrend)
        {
        // some function to check if current bar is a high bar
        myHighBarCounter++; //increment an int variable called myHighCounter

        // some function to check if current bar is a low bar
        myLowBarCounter++; //increment an int variable called myLowCounter

        }




        Comment


          #5
          How is a persistence bar Trend initialised and read through from bar to bar that can result in up or down Trend?

          Comment


            #6
            Hello Emma1,

            Thanks for your reply.

            I'm still not clear on the technicalities of what you are looking for, could you elaborate on what "persistence bar Trend initialised" means so I can advise how NS can be used to read this?

            Comment


              #7
              hello , NinjaTrader_PaulH, please ,is way or area of state event to place a variable that will allow bar to bar reading to persist in trend high low..

              Comment


                #8
                Hello Emma1,

                Thanks for your efforts to clarify.

                How do you currently define a trend?

                Can you provide a screenshot that illustrates what you would like to accomplish?

                Comment


                  #9

                  Thank you Paul. One way I define an up trend is when plot 1 of my custom indicator exceeds the value of the most recent swing high of plot 1, and I define a downtrend when plot 2 drops below the most recent swing low of plot 2. I don't have a screenshot, but my primary questions are:

                  1) Where do I define my variable "Trend" so it persists from bar to bar. Would it be for example created under State.Setdefaults or State.Configure?


                  2) Is under OnBarUpdate() the best place to test for the Trend conditions and set the Trend variable value?

                  Comment


                    #10
                    Hello Emma1,

                    Thanks for your reply.

                    If your variable 'Trend" is only to be used in the indicator then you could create it at the class level (I place mine just before OnStateChange() for ease of reading).

                    Yes, you can certainly use OnBarUpdate() for your trend coding. If you create your variable at the class level, then you could also create other methods outside of OnBarUpdate() and be able to access the variable.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    571 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    331 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
                    549 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    549 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X