OPEN-SOURCE SCRIPT
Smart Volatility Squeeze + Trend Filter

Smart Volatility Squeeze + Trend Filter
This advanced indicator detects low-volatility squeeze conditions and plots breakout signals, helping you spot strong price moves before they happen.
How it works
This script combines Bollinger Bands (BB) and the Keltner Channel (KC) — two popular volatility tools — to identify squeeze setups:
A squeeze occurs when the Bollinger Bands contract and move completely inside the Keltner Channel. This means the market is quiet and volatility is low — often right before a significant breakout.
When the squeeze condition is active, the background highlights the chart area with a soft color that gradually intensifies the longer the squeeze lasts. This gives a clear visual cue that pressure is building.
A breakout signal triggers when price crosses above the upper Bollinger Band (bullish) or below the lower Bollinger Band (bearish) — confirming that the squeeze has ended and a new impulse is likely starting.
To reduce false breakouts, you can enable the built-in trend filter. By default, it uses a simple EMA: breakouts are confirmed only if the price action aligns with the overall trend direction.
Key features
🔹 Bollinger Bands + Keltner Channel squeeze detection
🔹 Automatic squeeze marker and background shading
🔹 Breakout arrows for up and down signals
🔹 Optional trend filter with adjustable EMA length
🔹 Works on any market: crypto, stocks, forex, indices
🔹 Fully adjustable inputs for BB, KC and trend filter
🔹 Built-in ready-to-use alerts for breakouts
How to use
Watch for areas where the squeeze condition appears — the background will highlight them.
Wait for a breakout arrow to appear outside the bands.
Use the trend filter to focus only on breakouts in the dominant trend direction.
Combine with your existing risk management and confirmation tools.
Inputs
BB Length & StdDev: Control the Bollinger Bands settings.
KC EMA Length & ATR Multiplier: Control the Keltner Channel width.
Trend Filter Length: Adjust how smooth or sensitive the trend filter is.
Use Trend Filter: Enable or disable confirmation by trend direction.
Disclaimer
⚠️ This script is for educational purposes only and does not constitute financial advice. Always test any strategy thoroughly and trade at your own risk.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.