OPEN-SOURCE SCRIPT
Hilbert Bandwidth [LB]

🔬 Concept
The Hilbert Bandwidth Index, derived from John Ehlers' analytic signal approach, measures the instantaneous stability of the dominant market cycle by computing the bandwidth — the absolute deviation between the raw instantaneous period and its smoothed counterpart. A narrow bandwidth indicates a clean, well-defined cycle suitable for trading.
📐 Mathematical Foundation
The price median is transformed via a 7‑coefficient FIR Hilbert Transform to extract the analytic signal's real and imaginary components :
real = 0.0962·P[t] + 0.5769·P[t-2] - 0.5769·P[t-4] - 0.0962·P[t-6]
imag = 0.0962·P[t-1] + 0.5769·P[t-3] - 0.5769·P[t-5] - 0.0962·P[t-7]
The instantaneous phase φ is obtained via the two‑argument arctangent of imag and real. After exponential smoothing, the phase difference Δφ between consecutive bars yields the instantaneous period :
T = 2π / |Δφ|
Finally, the bandwidth is defined as :
B = |T - EMA(T, L)|
where L is the period smoothing length. The result is expressed in bars.
🎯 What Problem Does It Solve ?
Traditional cycle indicators assume a persistent dominant cycle, producing unreliable signals during chaotic or transitional markets — the Hilbert Bandwidth quantifies cycle cleanliness in real time, allowing traders to filter out low‑quality cyclic signals and act only when the market exhibits a stable, tradeable rhythm.
📊 How To Interpret
Bandwidth below threshold (background colored) → the dominant cycle is narrow, well‑defined, and stable ; trend‑following and cycle‑based strategies have higher probability of success.
Bandwidth above threshold → the cycle is broad and unstable ; the market is either noisy or in transition ; avoid cycle‑dependent entries.
Bandwidth rapidly contracting → the market is shifting from chaos to order ; anticipate a breakout or the emergence of a clean trend.

⚙️ Parameters
Phase Smoothing – exponential smoothing length applied to the instantaneous phase (default 50) ; higher values stabilize the phase estimate but introduce lag.
Period Smoothing – EMA length applied to the instantaneous period (default 10) ; controls the responsiveness of the bandwidth calculation.
Narrow Band Threshold – the bandwidth value in bars below which the cycle is considered "clean" (default 3.0) ; the background is highlighted when bandwidth falls below this level.
📚 Reference
Ehlers J.F., "Rocket Science for Traders : Digital Signal Processing Applications", Chapter 7 – The Hilbert Transform, John Wiley & Sons, 2001.
Ehlers J.F., "Cycle Analytics for Traders", Chapter 9 – Bandwidth Measurement, John Wiley & Sons, 2014.
The Hilbert Bandwidth Index, derived from John Ehlers' analytic signal approach, measures the instantaneous stability of the dominant market cycle by computing the bandwidth — the absolute deviation between the raw instantaneous period and its smoothed counterpart. A narrow bandwidth indicates a clean, well-defined cycle suitable for trading.
📐 Mathematical Foundation
The price median is transformed via a 7‑coefficient FIR Hilbert Transform to extract the analytic signal's real and imaginary components :
real = 0.0962·P[t] + 0.5769·P[t-2] - 0.5769·P[t-4] - 0.0962·P[t-6]
imag = 0.0962·P[t-1] + 0.5769·P[t-3] - 0.5769·P[t-5] - 0.0962·P[t-7]
The instantaneous phase φ is obtained via the two‑argument arctangent of imag and real. After exponential smoothing, the phase difference Δφ between consecutive bars yields the instantaneous period :
T = 2π / |Δφ|
Finally, the bandwidth is defined as :
B = |T - EMA(T, L)|
where L is the period smoothing length. The result is expressed in bars.
🎯 What Problem Does It Solve ?
Traditional cycle indicators assume a persistent dominant cycle, producing unreliable signals during chaotic or transitional markets — the Hilbert Bandwidth quantifies cycle cleanliness in real time, allowing traders to filter out low‑quality cyclic signals and act only when the market exhibits a stable, tradeable rhythm.
📊 How To Interpret
Bandwidth below threshold (background colored) → the dominant cycle is narrow, well‑defined, and stable ; trend‑following and cycle‑based strategies have higher probability of success.
Bandwidth above threshold → the cycle is broad and unstable ; the market is either noisy or in transition ; avoid cycle‑dependent entries.
Bandwidth rapidly contracting → the market is shifting from chaos to order ; anticipate a breakout or the emergence of a clean trend.
⚙️ Parameters
Phase Smoothing – exponential smoothing length applied to the instantaneous phase (default 50) ; higher values stabilize the phase estimate but introduce lag.
Period Smoothing – EMA length applied to the instantaneous period (default 10) ; controls the responsiveness of the bandwidth calculation.
Narrow Band Threshold – the bandwidth value in bars below which the cycle is considered "clean" (default 3.0) ; the background is highlighted when bandwidth falls below this level.
📚 Reference
Ehlers J.F., "Rocket Science for Traders : Digital Signal Processing Applications", Chapter 7 – The Hilbert Transform, John Wiley & Sons, 2001.
Ehlers J.F., "Cycle Analytics for Traders", Chapter 9 – Bandwidth Measurement, John Wiley & Sons, 2014.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.