Percent R
All functions · nseries package
PercentR
func (s Series) PercentR(h, l, c Series, n int) Series
PercentR returns series whereby each value represents the percentage in the range (of the last n bars) of the closing price. It is effectively the Williams %R calculation but with a return value range of 0 - 100. Mismatched input lengths return a zero-filled series of the receiver’s length.
The output is on a 0 to 100 scale, 100 - 100*(HH - c)/(HH - LL) over the last n bars; the receiver is used only for its length. Bars 0 to n-2 are exactly 50 (warm-up), not 0: the first valid index is n-1 and the minimum length is n, and n > len(s) gives all 50. 50 is mid-range; trim the bars before n-1 (Window(-(n-1))) before a moving average, because a NaN mask would poison a recursive average, and trim or mask them (SetN(n-1, math.NaN())) before a crossing rule. A flat window (HH == LL) gives 100, so the warm-up and flat values differ. This warm-up was reviewed in GLE-254 (3 October 2026) and kept: 0 would be the oversold extreme.