OPEN-SOURCE SCRIPT
Fisher Transform of Williams %R - Divergence

Fisher Transform of Williams %R — Divergence
Overview
This indicator applies John Ehlers' Fisher Transform to Larry Williams' %R oscillator, then layers a pivot-based regular/hidden divergence engine and a Fisher/Trigger crossover signal on top of it. The goal is to combine the sharp, well-defined turning points that the Fisher Transform produces with the momentum context of Williams %R, so that reversals show up as cleaner, more clearly separated peaks and troughs than the raw oscillator gives you — and then to automatically flag price/oscillator divergences at those points.
Credits
The Fisher Transform is a statistical technique introduced to trading by John F. Ehlers (see his paper "Using The Fisher Transform," Stocks & Commodities magazine). It converts an oscillator's probability distribution into a roughly Gaussian (bell-curve) distribution, which sharpens turning points and reduces the ambiguity that flat, range-bound oscillator readings normally produce.
Williams %R is a momentum oscillator developed by Larry Williams, measuring the current close relative to the high-low range over a lookback period.
This script normalizes Williams %R to a 0–1 range and runs that normalized value through Ehlers' Fisher Transform formula, rather than applying the transform to raw price or to a different oscillator. The divergence engine, cross-signal logic, zone filtering, and signal-spacing controls are original additions built for this script.
How it works
Williams %R is calculated over Williams %R Length bars: 100 × (source − highest high) / (highest high − lowest low).
That value is normalized to a 0–1 range using the highest/lowest %R over Fisher Transform Length bars, then rescaled to −1…+1.
The normalized value is smoothed (0.66 × normalized + 0.67 × previous) and clamped to ±0.999 to keep the Fisher formula well-defined.
The Fisher Transform is applied: 0.5 × ln((1+x)/(1−x)) + 0.5 × previous Fisher value. This is the plotted "Fisher %R" line.
A one-bar-delayed copy of the Fisher line acts as the Trigger line, used for crossover signals.
Divergence detection: the script finds confirmed pivot highs/lows on the Fisher line (using Pivot Left/Right Lookback), then looks back within a Min/Max Lookback Range window for a prior pivot of the same type to compare against price:
Regular Bullish: price makes a lower low while Fisher makes a higher low (potential reversal up).
Hidden Bullish: price makes a higher low while Fisher makes a lower low (trend continuation up).
Regular Bearish / Hidden Bearish: mirror logic on pivot highs.
Cross signals: independent triangle markers plot whenever the Fisher line crosses above/below its own Trigger line — a faster, divergence-independent momentum confirmation.
Parameters
Williams %R Length — lookback for the base %R calculation; shorter = more responsive, noisier.
Fisher Transform Length — lookback used to normalize %R before the transform; controls how "stretched" the Fisher output is.
Source — price input for %R (default close).
Overbought / Oversold Level — Fisher levels used for the background zone and, optionally, to filter divergence signals.
Pivot Left/Right Lookback — bars required on each side to confirm a swing high/low on the Fisher line; larger values = fewer but more reliable pivots.
Max/Min Lookback Range — bar-distance window searched for a comparable prior pivot when checking divergence.
Min Bars Between Same-Type Signals — cooldown to suppress rapid repeat signals of the same type.
Show Regular/Hidden Divergence — toggle each divergence class independently.
Require OB/OS Zone for Divergence — when on, only fires divergence signals when the relevant pivot is inside the overbought/oversold zone, cutting down low-quality mid-range signals.
Show Fisher/Trigger Cross Signals — toggle the crossover triangles.
Color inputs — purely visual, no effect on signal logic.
How to use it
Watch the Fisher line relative to the Trigger line and the OB/OS zone the way you would any oscillator, but expect sharper, more decisive turns than plain Williams %R.
Solid divergence lines/labels ("Reg Bull," "Reg Bear") mark classic reversal-warning divergences; dashed ones ("Hdn Bull," "Hdn Bear") mark continuation divergences, useful for adding to an existing trend rather than fading it.
Triangle cross signals can be used as a faster, standalone trigger, or as confirmation once a divergence has printed.
All four divergence types and both cross directions have built-in alertcondition() calls, so alerts can be set directly from the "Create Alert" dialog without any manual configuration.
What it solves / how it differs from other tools
Plain Williams %R divergence detection is noisy because %R saturates near ±100 across a wide range of price action, blurring pivots. Running it through the Fisher Transform first compresses that noise into sharper, more Gaussian-shaped peaks, giving divergence detection a cleaner signal to work from than a raw-oscillator approach.
Unlike many public Fisher Transform scripts (which typically transform price directly, or transform RSI/Stochastic), this one is specifically built on Williams %R, giving a different — often earlier — read on exhaustion at range extremes.
The zone filter and same-type signal cooldown are both configurable, letting users trade off signal frequency against signal quality, which many divergence scripts don't expose.
Notes / Disclaimer
This indicator is a technical analysis tool and does not constitute financial advice. It repaints only in the sense that divergence lines/labels are drawn after pivot confirmation (lbR bars after the pivot bar), which is standard for any pivot-based divergence tool and is by design — the underlying Fisher/Trigger plot values themselves do not repaint. As with any oscillator, past signals do not guarantee future performance; test and combine with your own risk management before live use.
Overview
This indicator applies John Ehlers' Fisher Transform to Larry Williams' %R oscillator, then layers a pivot-based regular/hidden divergence engine and a Fisher/Trigger crossover signal on top of it. The goal is to combine the sharp, well-defined turning points that the Fisher Transform produces with the momentum context of Williams %R, so that reversals show up as cleaner, more clearly separated peaks and troughs than the raw oscillator gives you — and then to automatically flag price/oscillator divergences at those points.
Credits
The Fisher Transform is a statistical technique introduced to trading by John F. Ehlers (see his paper "Using The Fisher Transform," Stocks & Commodities magazine). It converts an oscillator's probability distribution into a roughly Gaussian (bell-curve) distribution, which sharpens turning points and reduces the ambiguity that flat, range-bound oscillator readings normally produce.
Williams %R is a momentum oscillator developed by Larry Williams, measuring the current close relative to the high-low range over a lookback period.
This script normalizes Williams %R to a 0–1 range and runs that normalized value through Ehlers' Fisher Transform formula, rather than applying the transform to raw price or to a different oscillator. The divergence engine, cross-signal logic, zone filtering, and signal-spacing controls are original additions built for this script.
How it works
Williams %R is calculated over Williams %R Length bars: 100 × (source − highest high) / (highest high − lowest low).
That value is normalized to a 0–1 range using the highest/lowest %R over Fisher Transform Length bars, then rescaled to −1…+1.
The normalized value is smoothed (0.66 × normalized + 0.67 × previous) and clamped to ±0.999 to keep the Fisher formula well-defined.
The Fisher Transform is applied: 0.5 × ln((1+x)/(1−x)) + 0.5 × previous Fisher value. This is the plotted "Fisher %R" line.
A one-bar-delayed copy of the Fisher line acts as the Trigger line, used for crossover signals.
Divergence detection: the script finds confirmed pivot highs/lows on the Fisher line (using Pivot Left/Right Lookback), then looks back within a Min/Max Lookback Range window for a prior pivot of the same type to compare against price:
Regular Bullish: price makes a lower low while Fisher makes a higher low (potential reversal up).
Hidden Bullish: price makes a higher low while Fisher makes a lower low (trend continuation up).
Regular Bearish / Hidden Bearish: mirror logic on pivot highs.
Cross signals: independent triangle markers plot whenever the Fisher line crosses above/below its own Trigger line — a faster, divergence-independent momentum confirmation.
Parameters
Williams %R Length — lookback for the base %R calculation; shorter = more responsive, noisier.
Fisher Transform Length — lookback used to normalize %R before the transform; controls how "stretched" the Fisher output is.
Source — price input for %R (default close).
Overbought / Oversold Level — Fisher levels used for the background zone and, optionally, to filter divergence signals.
Pivot Left/Right Lookback — bars required on each side to confirm a swing high/low on the Fisher line; larger values = fewer but more reliable pivots.
Max/Min Lookback Range — bar-distance window searched for a comparable prior pivot when checking divergence.
Min Bars Between Same-Type Signals — cooldown to suppress rapid repeat signals of the same type.
Show Regular/Hidden Divergence — toggle each divergence class independently.
Require OB/OS Zone for Divergence — when on, only fires divergence signals when the relevant pivot is inside the overbought/oversold zone, cutting down low-quality mid-range signals.
Show Fisher/Trigger Cross Signals — toggle the crossover triangles.
Color inputs — purely visual, no effect on signal logic.
How to use it
Watch the Fisher line relative to the Trigger line and the OB/OS zone the way you would any oscillator, but expect sharper, more decisive turns than plain Williams %R.
Solid divergence lines/labels ("Reg Bull," "Reg Bear") mark classic reversal-warning divergences; dashed ones ("Hdn Bull," "Hdn Bear") mark continuation divergences, useful for adding to an existing trend rather than fading it.
Triangle cross signals can be used as a faster, standalone trigger, or as confirmation once a divergence has printed.
All four divergence types and both cross directions have built-in alertcondition() calls, so alerts can be set directly from the "Create Alert" dialog without any manual configuration.
What it solves / how it differs from other tools
Plain Williams %R divergence detection is noisy because %R saturates near ±100 across a wide range of price action, blurring pivots. Running it through the Fisher Transform first compresses that noise into sharper, more Gaussian-shaped peaks, giving divergence detection a cleaner signal to work from than a raw-oscillator approach.
Unlike many public Fisher Transform scripts (which typically transform price directly, or transform RSI/Stochastic), this one is specifically built on Williams %R, giving a different — often earlier — read on exhaustion at range extremes.
The zone filter and same-type signal cooldown are both configurable, letting users trade off signal frequency against signal quality, which many divergence scripts don't expose.
Notes / Disclaimer
This indicator is a technical analysis tool and does not constitute financial advice. It repaints only in the sense that divergence lines/labels are drawn after pivot confirmation (lbR bars after the pivot bar), which is standard for any pivot-based divergence tool and is by design — the underlying Fisher/Trigger plot values themselves do not repaint. As with any oscillator, past signals do not guarantee future performance; test and combine with your own risk management before live use.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.