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

Ranking Indicator Values

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

    #16
    Well, I wouldn't actually be doing a percentile ranking of a percentile ranking. It would be more like a percentile ranking of the average value of 3 indicators, and one of those 3 indicators is a percentile ranking of the daily changes.

    I do this manually in Excel on daily data right now and I have compared these doubly-ranked values against just using the arithmetic average of the 3 indicators and they are similar, but definitely not identical.

    Comment


      #17
      Originally posted by PhillyD View Post
      Well, I wouldn't actually be doing a percentile ranking of a percentile ranking. It would be more like a percentile ranking of the average value of 3 indicators, and one of those 3 indicators is a percentile ranking of the daily changes.

      I do this manually in Excel on daily data right now and I have compared these doubly-ranked values against just using the arithmetic average of the 3 indicators and they are similar, but definitely not identical.
      In that case you would need to define a new DataSeries in the Variables section of the indicator, intialize the DataSeries in the Initialize() section of the indicator and apply the following logic in OnBarUpdate():

      -> first run the percentile ranking algorithm on your input series
      -> then calculate the arithmetic mean of the 3 indicators and write the result to the newly created DataSereis
      -> finally apply the percentile ranking algorithm to the new DataSeries

      Percentile ranking is an interesting way of normalizing an indicator over a number N of given bars. Alternatively you could use the Z-score for doing the normlization.

      Comment


        #18
        Originally posted by anachronist View Post
        If you still need this, I have just uploaded a Percentile indicator to the NT7 file sharing area. You can use it to plot median values of the last N bars, or any percentile of the last N bars. It's an efficient, fast algorithm, too.
        @anachronist, the part of your indicator getPercentile(), does it return a percentile if passed an array of values? I have a need for this as I want to calculate percentiles based on portions of an array.

        Comment


          #19
          Originally posted by forrestang View Post
          @anachronist, the part of your indicator getPercentile(), does it return a percentile if passed an array of values? I have a need for this as I want to calculate percentiles based on portions of an array.
          No, getPercentile() takes only the desired percentile (0 to 100) as an argument. You cannot pass an array of values to it. Internally the indicator maintains a sorted list of the last N values in a data series. Most of the code in the getPercentile() function just calculates the array index corresponding to the desired percentile and, because this is almost never a whole number, it interpolates between the values in the nearest array indices to return a result.

          If you want the percentile of an array, it's simple. Just sort the array and calculate the array index closest to your desired percentile. The value at the nearest array index will be the percentile. If you want to get fancy, you can interpolate like my indicator does.

          Comment


            #20
            thanks for the snippet, Harry. I've been trying to get a percentile working for weeks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            59 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            36 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            7 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            21 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            10 views
            0 likes
            Last Post cre8able  
            Working...
            X