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.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。