Percent Rank Calculation

95

I would like to use Percent Rank in an indicator. It is exactly as Connors say:

"Relative Magnitude of Price Change: It looks at the size of today’s price change in relation to previous price changes. We do this by using a Percent Rank

calculation, which may also be referred to as a “percentile”. Basically, the Percent Rank value tells us the percentage of values in the look‐back period that are less than the current value.

For this calculation, we measure price change not in dollars and cents, but as a percentage of the previous day’s price. This percentage gain or loss is typically referred to as the one‐day

return. So if yesterday’s closing price was \$80.00, and today’s price is \$81.60, the one‐day return is (\$81.60 ‐ \$80.00) / \$80.00 = 0.02 = 2.0%.

To determine the Percent Rank, we need to establish a look‐back period. The Percent Rank value is then the number of values in the look‐back period that are less than the current value,

divided by the total number of values. For example, if the look‐back period is 20 days, then we would compare today’s 2.0% return to the one‐day returns from each of the previous 20 days.

Let’s assume that three of those values are less than 2.0%. We would calculate Percent Rank as:

Percent Rank = 3 / 20 = 0.15 = 15%"

Appended the code that I have write but it not work.

Thanks for help.

Files:
95

edilsonfsantos:

I would like to use Percent Rank in an indicator. It is exactly as Connors say:

"Relative Magnitude of Price Change: It looks at the size of today’s price change in relation to previous price changes. We do this by using a Percent Rank

calculation, which may also be referred to as a “percentile”. Basically, the Percent Rank value tells us the percentage of values in the look‐back period that are less than the current value.

For this calculation, we measure price change not in dollars and cents, but as a percentage of the previous day’s price. This percentage gain or loss is typically referred to as the one‐day

return. So if yesterday’s closing price was \$80.00, and today’s price is \$81.60, the one‐day return is (\$81.60 ‐ \$80.00) / \$80.00 = 0.02 = 2.0%.

To determine the Percent Rank, we need to establish a look‐back period. The Percent Rank value is then the number of values in the look‐back period that are less than the current value,

divided by the total number of values. For example, if the look‐back period is 20 days, then we would compare today’s 2.0% return to the one‐day returns from each of the previous 20 days.

Let’s assume that three of those values are less than 2.0%. We would calculate Percent Rank as:

Percent Rank = 3 / 20 = 0.15 = 15%"

Appended the code that I have write but it not work.

Thanks for help.

I could encode the indicator. After hard work.

If one wants to improve it, feel free.

Files: