williams_r
Williams %R momentum oscillator
williams_r(period)
A momentum oscillator that measures overbought and oversold conditions. Similar to Stochastic %K but inverted and scaled to -100 to 0.
Parameters
- period (int): Number of periods for high-low range calculation
- Common values: 14 (standard), 20, 50
Formula
Williams %R = -100 * (Highest High - Close) / (Highest High - Lowest Low)
Where:
- Highest High = Maximum high over period
- Lowest Low = Minimum low over period
- Close = Current closing price
Examples
williams_r(14); # Standard 14-period Williams %R
williams_r(20); # 20-period Williams %R
williams_r(14) > -20; # Overbought condition
williams_r(14) < -80; # Oversold condition
Returns
Williams %R value ranging from -100 (most oversold) to 0 (most overbought)
Notes
- Values > -20 indicate overbought conditions
- Values < -80 indicate oversold conditions
- Inverted scale compared to Stochastic (0 is top, -100 is bottom)
- Returns -50 when range is zero (avoid division by zero)