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

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?
    Paul H.NinjaTrader Customer Service

    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

        }




        Paul H.NinjaTrader Customer Service

        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?
            Paul H.NinjaTrader Customer Service

            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?

                Paul H.NinjaTrader Customer Service

                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.

                    Paul H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Kaledus, Today, 01:29 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post Kaledus
                    by Kaledus
                     
                    Started by PaulMohn, Today, 12:36 PM
                    1 response
                    16 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by yertle, Yesterday, 08:38 AM
                    8 responses
                    37 views
                    0 likes
                    Last Post ryjoga
                    by ryjoga
                     
                    Started by rdtdale, Today, 01:02 PM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by alifarahani, Today, 09:40 AM
                    3 responses
                    19 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X