Williams %R (Larry Williams) — how far the close sits below the
highest high of the trailing period bars, as a percentage of the range,
bounded −100..0:
%R= −100 · (HH − close) / (HH − LL)
Appends one column; undefined for the first period − 1 rows.
Definition
TA-Lib's WILLR. Verified bar-for-bar in the oracle fixture with an
identical warm-up, agreeing to 1.4e-14.
%R is the fast stochastic %K shifted down by 100 — 100·(c−LL)/(HH−LL) − 100 rearranges to the formula above — so it is computed on the same
kernel as stochastic rather than owning a second division, and a
test pins the identity williamsR ≡ stochastic({ slowing: 1 }).K − 100.
What differs is convention, not maths: %R is quoted negative and
unsmoothed, and its "overbought" reads above −20 where %K's reads
above 80.
Edges
A flat window (HH === LL) is undefined — the one deliberate delta
from TA-Lib, which reports 0. 0 is also %R's value for "close at
the very top of a real range", so TA-Lib's answer cannot distinguish the
two; and the same TA-Lib convention gives %K0 — the very bottom —
for the same bar. The kernel (percentOfRangeValues) reports no
value instead, for both studies.
Bounded −100..0 whenever low ≤ close ≤ high; redirect close at
a column the range does not bound and it reads outside, unclamped.
Scale-invariant, like RSI; a leading gap shifts the start; an
interior gap in close costs that bar only, and one in high/low is
skipped by the range (core's reducer policy).
Williams %R (Larry Williams) — how far the close sits below the highest high of the trailing
periodbars, as a percentage of the range, bounded−100..0:Appends one column;
undefinedfor the firstperiod − 1rows.Definition
TA-Lib's
WILLR. Verified bar-for-bar in the oracle fixture with an identical warm-up, agreeing to1.4e-14.%Ris the fast stochastic%Kshifted down by 100 —100·(c−LL)/(HH−LL) − 100rearranges to the formula above — so it is computed on the same kernel as stochastic rather than owning a second division, and a test pins the identitywilliamsR ≡ stochastic({ slowing: 1 }).K − 100. What differs is convention, not maths:%Ris quoted negative and unsmoothed, and its "overbought" reads above−20where%K's reads above80.Edges
HH === LL) isundefined— the one deliberate delta from TA-Lib, which reports0.0is also%R's value for "close at the very top of a real range", so TA-Lib's answer cannot distinguish the two; and the same TA-Lib convention gives%K0— the very bottom — for the same bar. The kernel (percentOfRangeValues) reports no value instead, for both studies.−100..0wheneverlow ≤ close ≤ high; redirectcloseat a column the range does not bound and it reads outside, unclamped.closecosts that bar only, and one inhigh/lowis skipped by the range (core's reducer policy).