OPEN-SOURCE SCRIPT
Bollinger BandWidth (Session-Adjusted)

Description
This indicator is a session-adjusted version of Bollinger BandWidth (BBW), specifically designed for instruments with limited trading hours, such as European stock indices (e.g., FTSE MIB, DAX, CAC, which trades from 09:00 to 17:30 CET — 8.5 hours) or individual stocks.
Standard Bollinger BandWidth on intraday charts can be distorted because calculations include non-trading periods (flat prices overnight), leading to inaccurate volatility readings.This script dynamically adjusts the Bollinger Bands calculation to approximate daily periods based on the actual trading session length, ensuring the BBW reflects true market volatility during active hours.
Key Features
Session-Adjusted Bollinger Bands:
The lookback period (default 20 days) is converted into an equivalent number of intraday candles based on your chart's timeframe and the session duration. This makes the indicator suitable for intraday timeframes (e.g., 5min, 15min, 1H) on limited-session assets.
Bollinger BandWidth (BBW) as Percentage:
Plots (Upper Band - Lower Band) / Middle Band * 100, a relative measure of volatility (higher values = wider bands = higher volatility).
Dynamic Expansion and Contraction Levels:
Red line: Highest BBW over the selected expansion lookback period (default 25 days) — highlights peak volatility levels.
Green line: Lowest BBW over the selected contraction lookback period (default 25 days) — highlights extreme squeezes (low volatility).
Fully customizable inputs for session hours, BB parameters, and dynamic level periods.
How It Works
Session Adjustment: Input session duration (default 8.5 hours).
The script calculates approximate candles per trading day for your current chart timeframe.
Bollinger Bands are computed using length * candlesPerDay bars, simulating a true multi-day calculation within intraday data.
BBW Calculation:
Basis: Simple Moving Average (SMA).
Deviation: Multiplier × Standard Deviation.
BBW = (2 × Deviation / Basis) × 100.
Dynamic Lines:
Expansion line uses the same session-adjusted period for highest BBW.
Contraction line uses the lowest BBW.
Usage and Trading Ideas
Bollinger BandWidth is a powerful volatility indicator popularized by John Bollinger. Low BBW values indicate band contraction ("Squeeze") — periods of low volatility often followed by strong breakouts. High BBW values indicate expansion — trending or volatile phases that may exhaust and lead to consolidation.
Squeeze Setup:
Watch for BBW dropping toward or below the dynamic low (green) line. This signals potential impending volatility expansion and breakout opportunities.
Expansion Confirmation:
BBW rising above the dynamic high (red) line suggests strong volatility — useful for trend-following or avoiding counter-trend trades.
Combine with price action (e.g., break of support/resistance), volume, or momentum indicators (RSI, MACD) for directional bias.
Ideal for intraday or swing trading on European indices, stocks, or other limited-session instruments where standard BBW would be misleading.
This adjustment makes the indicator more accurate on lower timeframes compared to built-in versions, providing cleaner volatility signals aligned with real trading sessions.
Enjoy the script — feedback welcome!
This indicator is a session-adjusted version of Bollinger BandWidth (BBW), specifically designed for instruments with limited trading hours, such as European stock indices (e.g., FTSE MIB, DAX, CAC, which trades from 09:00 to 17:30 CET — 8.5 hours) or individual stocks.
Standard Bollinger BandWidth on intraday charts can be distorted because calculations include non-trading periods (flat prices overnight), leading to inaccurate volatility readings.This script dynamically adjusts the Bollinger Bands calculation to approximate daily periods based on the actual trading session length, ensuring the BBW reflects true market volatility during active hours.
Key Features
Session-Adjusted Bollinger Bands:
The lookback period (default 20 days) is converted into an equivalent number of intraday candles based on your chart's timeframe and the session duration. This makes the indicator suitable for intraday timeframes (e.g., 5min, 15min, 1H) on limited-session assets.
Bollinger BandWidth (BBW) as Percentage:
Plots (Upper Band - Lower Band) / Middle Band * 100, a relative measure of volatility (higher values = wider bands = higher volatility).
Dynamic Expansion and Contraction Levels:
Red line: Highest BBW over the selected expansion lookback period (default 25 days) — highlights peak volatility levels.
Green line: Lowest BBW over the selected contraction lookback period (default 25 days) — highlights extreme squeezes (low volatility).
Fully customizable inputs for session hours, BB parameters, and dynamic level periods.
How It Works
Session Adjustment: Input session duration (default 8.5 hours).
The script calculates approximate candles per trading day for your current chart timeframe.
Bollinger Bands are computed using length * candlesPerDay bars, simulating a true multi-day calculation within intraday data.
BBW Calculation:
Basis: Simple Moving Average (SMA).
Deviation: Multiplier × Standard Deviation.
BBW = (2 × Deviation / Basis) × 100.
Dynamic Lines:
Expansion line uses the same session-adjusted period for highest BBW.
Contraction line uses the lowest BBW.
Usage and Trading Ideas
Bollinger BandWidth is a powerful volatility indicator popularized by John Bollinger. Low BBW values indicate band contraction ("Squeeze") — periods of low volatility often followed by strong breakouts. High BBW values indicate expansion — trending or volatile phases that may exhaust and lead to consolidation.
Squeeze Setup:
Watch for BBW dropping toward or below the dynamic low (green) line. This signals potential impending volatility expansion and breakout opportunities.
Expansion Confirmation:
BBW rising above the dynamic high (red) line suggests strong volatility — useful for trend-following or avoiding counter-trend trades.
Combine with price action (e.g., break of support/resistance), volume, or momentum indicators (RSI, MACD) for directional bias.
Ideal for intraday or swing trading on European indices, stocks, or other limited-session instruments where standard BBW would be misleading.
This adjustment makes the indicator more accurate on lower timeframes compared to built-in versions, providing cleaner volatility signals aligned with real trading sessions.
Enjoy the script — feedback welcome!
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.