OPEN-SOURCE SCRIPT

Williams%R Trend Signals | Astral Vision

1 200
Williams %R Trend Signals | Astral Vision 🌠💠

Williams %R measures where the current close sits within the high-low range of the past N bars, expressed on a scale from 0 to −100.
Values near 0 indicate price is closing at the top of its recent range; values near 100 indicate price is closing at the bottom. Unlike RSI, %R is not smoothed internally, it reacts immediately to price extremes, making it sensitive to momentum shifts at cycle turning points.

This indicator computes Williams %R on the weekly timeframe regardless of chart resolution, then applies a short SMA to reduce week-to-week noise.
Trend signals fire when the smoothed %R crosses a configurable bull or bear threshold, marking the weekly bars where momentum has definitively shifted regime.
Each signal is projected as a full-height glowing vertical line on the price chart, making the historical record of macro trend changes immediately visible across the entire chart history.

Calculation ⚙️

`%R = 100 × (close − Highest(close, length)) / (Highest(close, length) − Lowest(close, length))`

`SMA %R = SMA(%R, sma_length)`

Both are computed on the weekly timeframe. A bull signal fires when the smoothed %R crosses above the bull threshold; a bear signal fires when it crosses below the bear threshold.
Both thresholds are evaluated on the SMA, not the raw %R, preventing single-bar spikes from triggering signals.

Plots 📊
  • Raw Williams %R line (thin), colored by position relative to the bull threshold
  • Smoothed SMA %R line (thick), colored by the same logic
  • Bull and bear threshold lines
  • Full-height vertical lines on the price chart at each signal bar, rendered with a 4-layer glow (widths 3/6/12/20, transparencies 0/40/65/82) in positive or negative color


Inputs 🎛️
  • `Williams %R Length`: lookback period for highest/lowest range calculation (default 40 weeks)
  • `SMA Length`: smoothing applied to raw %R before threshold evaluation (default 4 weeks)
  • `Bull Threshold`: SMA %R level whose upward crossing fires a bull signal (default −90)
  • `Bear Threshold`: SMA %R level whose downward crossing fires a bear signal (default −30)


Colors 🎨

5 Astral Vision presets + custom override. Default: Futura. Positive color applies to bull signals and %R readings below the bull threshold; negative color applies to bear signals and readings above it.

Purpose 🎯

Standard Williams %R indicators operate on the chart's native timeframe and plot a raw oscillator with no signal logic, leaving the trader to visually interpret crosses manually across hundreds of bars. Daily %R generates excessive noise, while the macro-relevant signal is embedded in the weekly structure.

This indicator locks the calculation to the weekly timeframe and adds a smoothing layer specifically to filter noise before threshold evaluation, ensuring signals represent genuine momentum regime changes rather than transient fluctuations. The glowing vertical line output translates each weekly signal event directly onto any chart timeframe, daily, 4H, or lower, making the macro turning point visible at any resolution without requiring the trader to switch between timeframes.

Disclaimer ⭕️

It is not financial advice, not an investment recommendation, and not affiliated with any financial institution, research firm, or organization of any kind. All content is provided for educational and informational purposes only. Always conduct your own research before making any financial decision.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.