OPEN-SOURCE SCRIPT
Adaptive Volatility Bands [AVB]

Adaptive Volatility Bands (AVB) is a volatility-aware trend-following overlay indicator built on the Kaufman Adaptive Moving Average (KAMA) and dynamically adjusted Bollinger-style bands.

**Mathematical Foundation:**
The core of AVB is the Kaufman Efficiency Ratio (ER), which measures the ratio of directional price movement to total price movement over a lookback period. An ER near 1.0 indicates a strong trend with minimal noise; an ER near 0.0 indicates choppy, range-bound conditions. The KAMA uses this ratio to automatically adjust its smoothing constant — responding quickly during trends and slowly during consolidation.
The bands around the KAMA are not static standard deviations. Instead, they use an adaptive standard deviation that widens when the Efficiency Ratio is low (noisy markets) and tightens when ER is high (trending markets). This creates bands that contract during consolidation (squeeze) and expand during breakouts.

**Signal Logic:**
Buy signals are generated when price touches the lower band with RSI in oversold territory during an uptrend, or when a squeeze releases with price above the KAMA. Sell signals fire at the upper band with RSI overbought during a downtrend, or at squeeze release below KAMA. Volume confirmation is applied to filter low-conviction signals.

**Features:**
- Kaufman Adaptive Moving Average with adjustable fast/slow smoothing periods
- Adaptive volatility bands that respond to market efficiency
- Volatility squeeze detection with bar coloring
- RSI and volume filters for signal confirmation
- ATR-based stop-loss and take-profit levels
- Real-time dashboard showing efficiency ratio, RSI, volatility regime, and trend direction
- Fully customizable colors and parameters

**Use Cases:**
Suitable for forex, crypto, commodities, and equities across all timeframes. Works well on 15-minute to daily charts.
**Mathematical Foundation:**
The core of AVB is the Kaufman Efficiency Ratio (ER), which measures the ratio of directional price movement to total price movement over a lookback period. An ER near 1.0 indicates a strong trend with minimal noise; an ER near 0.0 indicates choppy, range-bound conditions. The KAMA uses this ratio to automatically adjust its smoothing constant — responding quickly during trends and slowly during consolidation.
The bands around the KAMA are not static standard deviations. Instead, they use an adaptive standard deviation that widens when the Efficiency Ratio is low (noisy markets) and tightens when ER is high (trending markets). This creates bands that contract during consolidation (squeeze) and expand during breakouts.
**Signal Logic:**
Buy signals are generated when price touches the lower band with RSI in oversold territory during an uptrend, or when a squeeze releases with price above the KAMA. Sell signals fire at the upper band with RSI overbought during a downtrend, or at squeeze release below KAMA. Volume confirmation is applied to filter low-conviction signals.
**Features:**
- Kaufman Adaptive Moving Average with adjustable fast/slow smoothing periods
- Adaptive volatility bands that respond to market efficiency
- Volatility squeeze detection with bar coloring
- RSI and volume filters for signal confirmation
- ATR-based stop-loss and take-profit levels
- Real-time dashboard showing efficiency ratio, RSI, volatility regime, and trend direction
- Fully customizable colors and parameters
**Use Cases:**
Suitable for forex, crypto, commodities, and equities across all timeframes. Works well on 15-minute to daily charts.
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.