PercentR (Function)
The PercentR function evaluates the price range over Length number of bars. It then returns a percentage of where the current price lies, related to the evaluated trading range.
Syntax
PercentR(Length)
Returns (Double)
A numeric value containing the current %R value.
Parameters
Name |
Type |
Description |
Length |
Numeric |
Sets the number of bars to consider in the calculation of PercentR. |
Remarks
The formula used to calculate the Percentage Range follows:
%R=100*((Hr-C)/(Hr-Lr))
…where
r = The time period selected
Hr = The highest High of that period
Lr = The lowest Low of that period
C = Today’s Close
The input Length can be hard coded with a whole number or can be replaced by a numeric simple input whose default value is a whole number.
Example
Plots the PercentR over a length of 10 bars.
Plot1(PercentR(10);
Reference
Williams, Larry. How I Made One Million Dollars Last Year Trading Commodities. Monterey, California: Conceptual Management, 1973 2nd edition.
To be consistent with other oscillators, PercentR takes William’s value and subtracts it from one hundred (100). For example, if William’s Percent R returns -80, PercentR will return 20.