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

HighestBar(High,Length)[x]

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

    HighestBar(High,Length)[x]

    I'm trying to reference the High or Low value of a DataSeries starting from a lookback period which is not the Current Bar (ie High[HighestBar(High,lookback)[x]]. I tried creating a DataSeries for HighestBar but all DataSeries are created as double yet previous data references are referenced as [int]. Any suggestions on how to accomplish this?
    Thanks.

    #2
    Hawk Arps,

    Are you attempting to store the index as well as the value or just the value of the highest high over lookback?

    A simple dataseries should work in the latter cast, you just use MyDataseries.Set( High[HighestBar(High,lookback)] )

    High[HighestBar(High,lookback)[x]] is incorrect, the HighestBar() function returns only 1 integer, not an array.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by Hawk Arps View Post
      I'm trying to reference the High or Low value of a DataSeries starting from a lookback period which is not the Current Bar (ie High[HighestBar(High,lookback)[x]]. I tried creating a DataSeries for HighestBar but all DataSeries are created as double yet previous data references are referenced as [int]. Any suggestions on how to accomplish this?
      Thanks.
      That is what MAX() and MIN() are used to do.

      Comment


        #4
        I want to find the Highest High over a lookback period, but I do not want the search for the Highest High to start from the current bar. I want the search to start from a previous bar on the chart.

        Comment


          #5
          Thanks Koganam, but I still don't know how many bars ago that high was.

          Comment


            #6
            MAX(High, 10)[10]

            for example would give you the highest high value 10 bars ago with a look back period of 10 bars.
            RayNinjaTrader Customer Service

            Comment


              #7
              Originally posted by Hawk Arps View Post
              Thanks Koganam, but I still don't know how many bars ago that high was.
              The maximum high (double)H, in the preceding (int)P bars, starting from the bar (int)S bars ago is:
              Code:
              double H = MAX(High, P)[S];

              Comment


                #8
                Thanks Koganam, This is what I came up with to identify the referenced bar...it seems to work.

                double HH=MAX(High,LLBAR-2)[LLBAR+1];
                int j=LLBAR+1;
                while (High[j]!=HH && j<CurrentBar-10)
                {
                j=j+1;
                }
                int HHBAR=j;

                Comment


                  #9
                  Originally posted by koganam View Post
                  The maximum high (double)H, in the preceding (int)P bars, starting from the bar (int)S bars ago is:
                  Code:
                  double H = MAX(High, P)[S];
                  Does that method of the maximum high works also on strategy?

                  Comment


                    #10
                    Originally posted by edward_bell View Post
                    Does that method of the maximum high works also on strategy?
                    All indicator methods can be called from a strategy.

                    Comment


                      #11
                      Originally posted by koganam View Post
                      All indicator methods can be called from a strategy.
                      I am not going to call an indicator. All I wanna do is to get the maximum high of 5 bars back within my strategy and compare it to the current bar high so that I can put an order at the higher price.

                      Comment


                        #12
                        Originally posted by edward_bell View Post
                        I am not going to call an indicator. All I wanna do is to get the maximum high of 5 bars back within my strategy and compare it to the current bar high so that I can put an order at the higher price.
                        MAX() is an indicator.

                        Comment


                          #13
                          Follow-Up question

                          Originally posted by NinjaTrader_AdamP View Post
                          Hawk Arps,

                          Are you attempting to store the index as well as the value or just the value of the highest high over lookback?

                          A simple dataseries should work in the latter cast, you just use MyDataseries.Set( High[HighestBar(High,lookback)] )

                          High[HighestBar(High,lookback)[x]] is incorrect, the HighestBar() function returns only 1 integer, not an array.

                          Please let me know if I may assist further.
                          So, how would you get the index (how far back) for the MAX value?

                          Comment


                            #14
                            Hello thekreme,

                            Thank you for your post.

                            Are you asking what to assign the period to for the MAX()? Or how to assign the period for the MAX()?

                            Comment


                              #15
                              I can get the max for the period but I was wondering how far back that max occurred so that I can use it elsewhere.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Brevo, Today, 01:45 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Brevo
                              by Brevo
                               
                              Started by aussugardefender, Today, 01:07 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post aussugardefender  
                              Started by pvincent, 06-23-2022, 12:53 PM
                              14 responses
                              240 views
                              0 likes
                              Last Post Nyman
                              by Nyman
                               
                              Started by TraderG23, 12-08-2023, 07:56 AM
                              9 responses
                              384 views
                              1 like
                              Last Post Gavini
                              by Gavini
                               
                              Started by oviejo, Today, 12:28 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post oviejo
                              by oviejo
                               
                              Working...
                              X