OPEN-SOURCE SCRIPT
ATC Bollinger Band Percentile v1.1

What It Is
The ATC Bollinger Band Percentile (ATC BBP) is a dual-layer oscillator that tells you two things simultaneously: where price sits inside its Bollinger envelope right now, and whether the current volatility environment is compressing, neutral, or expanding — measured against real historical data, not a hardcoded threshold.
Most Bollinger Band tools give you the bands. This one gives you the context behind the bands.
________________________________________
Who It's Built For
ATC BBP is designed for retail traders who already use Bollinger Bands or have tried them but found the raw %B reading too noisy or too vague to act on. If you've ever looked at a squeeze setup and wondered whether the bands were actually tight or just tighter than yesterday, this indicator was built to answer that question directly.
It works best for traders who use volatility as a filter before entering trend or breakout trades, want a cleaner and less reactive version of %B, or are building toward understanding normalized, statistically-grounded indicators.
________________________________________
Core Concept
Bollinger Bands place price in a dynamic envelope built from a moving average and standard deviation. The %B reading converts that envelope into a 0–100 scale: 100 means price is sitting on the upper band, 0 means price is on the lower band, and 50 means price is at the midpoint.
That's useful, but the raw reading is noisy and the bands themselves don't tell you whether they're wide or narrow relative to history. A band can look visually compressed on your chart and still be wider than it's been 75% of the time — or vice versa.
ATC BBP solves both problems. It smooths %B with a Hull Moving Average to reduce reactive noise, and it scores the current bandwidth as a percentile against a rolling window of its own history — so you always know objectively whether compression is real.
________________________________________
ATC Upgrades Over Standard %B
HMA Smoothing on %B The raw %B line reacts sharply to every candle. ATC BBP applies a Hull Moving Average to %B before it's plotted, cutting noise while preserving responsiveness. The raw %B is still available in the data window for comparison, but the smoothed version drives everything you see. You can adjust the smoothing length or disable it entirely.
Bandwidth Percentile Scoring This is the core ATC enhancement. Instead of asking "are the bands narrow?", ATC BBP asks "are the bands narrow relative to the last 125 bars of bandwidth history?" The bandwidth percentile is computed by ranking the current bandwidth against every value in the lookback window. A reading of 8% means the bands are tighter right now than they've been on 92% of recent bars. That's a real squeeze signal — not an eyeball call.
Empirical Zone Thresholds with Hysteresis The %B zone boundaries are not hardcoded round numbers. The defaults are set at empirically sensible levels and are fully adjustable. More importantly, every state transition — both the squeeze state and the %B zone — uses a configurable hysteresis band so the indicator doesn't flicker at the edges. Once a state is entered, it takes a meaningful move to exit it.
________________________________________
What's on the Chart
ATC BBP plots in a separate pane below your price chart.
The %B Line The smoothed %B oscillator on a 0–100 scale. The line changes color dynamically to reflect the current zone: green shades when price is in the lower portion of the bands, red shades in the upper portion, neutral grey for mid-range. When price tags or exceeds either band, the color deepens to full intensity. A fill between the %B line and the 50-level midline gives an immediate read on whether price is in the upper or lower half of the range.
Horizontal Reference Lines Five levels mark the key zones: lower extreme (0), lower quartile (20), midline (50), upper quartile (80), and upper extreme (100). Low-opacity colored background shading tints each zone — red above the upper quartile, green below the lower quartile, neutral in the middle.
Squeeze Pressure Bar Along the bottom of the pane, a colored bar marks the current squeeze state. Amber indicates a tight squeeze — bandwidth in the lowest percentile tier. Light yellow indicates a developing or loose squeeze. Blue indicates active volatility expansion. When no state is active, the bar disappears — the absence of color is meaningful. Diamond markers appear at the bar when a squeeze begins and again when expansion starts, so state transitions are never missed on a busy chart.
________________________________________
HUD Breakdown
The corner HUD (top right by default) gives you a live read of both indicator layers without having to inspect chart values:
Volatility — current squeeze state label: Tight Squeeze, Loose Squeeze, Expansion, or Neutral, color-coded to match the pressure bar
BW %-ile — the bandwidth percentile as a number, followed by a 10-block progress bar showing where current bandwidth sits on a visual scale from fully compressed to fully expanded
%B Zone — a text label for where price is in the envelope: Below Lower Band, Lower Quartile, Mid Range, Upper Quartile, or Above Upper Band
%B Reading — the smoothed %B value as a number
The HUD supports dark and light themes and can be repositioned to any corner of the pane.
________________________________________
Logic Layers
The indicator runs two independent state machines, each with its own hysteresis logic.
Squeeze State Machine Four states: Tight Squeeze (bandwidth percentile below the tight threshold), Loose Squeeze (between tight and loose thresholds), Neutral (mid-range bandwidth), and Expansion (above the expansion threshold). State transitions require the bandwidth percentile to move beyond the threshold by the hysteresis amount before the state flips. This prevents toggling at the boundary on marginal readings.
%B Zone State Machine Five zones tracking price location within the envelope: Below Lower Band, Lower Quartile, Mid Range, Upper Quartile, and Above Upper Band. The same hysteresis logic applies — once price enters a zone, it stays classified there until it moves decisively into the next zone.
The two machines run independently. You can be in a tight squeeze while price is in the upper quartile — which is a very different setup than a tight squeeze with price at the midline. The HUD shows both readings simultaneously so you always have the full picture.
________________________________________
Alerts
Seven alert conditions are built in.
BBP: Tight Squeeze Started — fires when the squeeze state first enters the tight tier. Use this to monitor compression setups across instruments before they break.
BBP: Tight Squeeze Released — fires when the tight squeeze breaks. This is the exit from compression, which may precede expansion or resolve back to neutral — both are meaningful.
BBP: Expansion Started — fires when bandwidth percentile crosses above the expansion threshold, confirming that volatility is breaking out of compression.
BBP: Price Above Upper Band — fires when %B reaches or exceeds 100, meaning price has tagged or broken through the upper band.
BBP: Price Below Lower Band — fires when %B reaches or falls below 0, meaning price has tagged or broken through the lower band.
BBP: %B Cross Above 50 — fires when smoothed %B crosses above the midline. Price location bias has shifted to the upper half of the envelope.
BBP: %B Cross Below 50 — fires when smoothed %B crosses below the midline. Price location bias has shifted to the lower half.
________________________________________
How to Trade With It
ATC BBP is a context indicator, not a signal generator. It tells you the volatility environment and price location so you can filter and frame your setups — it does not issue buy or sell signals on its own.
Step 1 — Check the Squeeze State First Before anything else, look at the HUD Volatility row and the pressure bar. Tight Squeeze means the market is coiling. Expansion means it's already moving. Neutral means neither is happening. This single read tells you what kind of market you're in before you look at anything else.
Step 2 — Use Squeeze Context to Filter Breakout Setups A tight squeeze is the setup condition for a potential expansion — it does not tell you which direction. When bandwidth is in the lowest 8–10 percentile of its history, start watching price action for the break, but wait for directional confirmation from your primary setup criteria before trading it. The squeeze tells you energy is building. Your edge tells you which way it breaks.
Step 3 — Use %B to Read Location Within the Setup Once you have a directional bias, %B tells you where price currently sits in the envelope. If you're looking for a long entry and %B is already above 80, price is extended toward the top of the range — it may be better to wait for a pullback toward the 50 midline. If %B is mid-range or lower quartile heading into a long setup, there's more room to run before hitting band resistance.
Step 4 — Look for Squeeze-Plus-Zone Confluence The highest-value reads come when both layers line up. A tight squeeze with %B at mid-range or lower quartile means compression is present and price has room to move higher if the break is bullish — watch for expansion to confirm with %B rising through 50. Expansion with %B crossing above 50 means volatility is moving and location bias is shifting bullish simultaneously — often the clearest confirmation that a breakout is real. Expansion with %B above 100 means price is already through the upper band in an expanding environment — valid in strong trends, a caution flag in range conditions.
Step 5 — Use Alerts for Multi-Instrument Monitoring If you're running ATC BBP across multiple instruments or timeframes, set the Tight Squeeze Started and Expansion Started alerts. These fire the moment a state changes so you're never watching the wrong chart while a setup develops elsewhere.
________________________________________
Settings Reference
Bollinger Bands BB Length (default 30) — period for the moving average and standard deviation calculation. Optimized default for QQQ. Increase for slower, more structural readings; decrease for more reactive readings on faster instruments.
BB StdDev Multiplier (default 1.6) — number of standard deviations for the band width. Optimized default for QQQ. Lower values tighten the bands and will increase the frequency of upper/lower extreme readings.
BB Source (default Close) — price source for the band calculation.
Smoothing %B HMA Smoothing (default 8) — Hull Moving Average length applied to %B. Set to 1 to disable smoothing and plot the raw %B line.
Squeeze Quality Bandwidth Percentile Window (default 125) — rolling lookback used to rank the current bandwidth. Larger windows produce more stable percentile readings against longer historical context.
Tight Squeeze Threshold (default 8) — bandwidth percentile below this level is classified as a tight squeeze.
Loose Squeeze Threshold (default 25) — bandwidth percentile between the tight threshold and this level is classified as a developing squeeze.
Expansion Threshold (default 75) — bandwidth percentile above this level is classified as active expansion.
State Hysteresis (default 3.0) — neutral band around each threshold. A state must be exceeded by this amount before the classification changes, preventing flicker on marginal readings.
%B Zones Upper Quartile (default 80) — %B above this is classified as Upper Quartile zone.
Lower Quartile (default 20) — %B below this is classified as Lower Quartile zone.
Upper Extreme (default 100) — %B at or above this is classified as Above Upper Band. Lower
Extreme (default 0) — %B at or below this is classified as Below Lower Band.
Visuals Shade %B Zones — toggles the background zone tinting on the oscillator pane. Show Squeeze Pressure Bar — toggles the colored state bar and diamond markers at the bottom of the pane. Color inputs for all states are fully adjustable if you prefer a different palette.
________________________________________
Recommended Instruments and Timeframes
ATC BBP is tested and validated on ES, NQ, CL, GC, SPY, QQQ, major equities, and major FX pairs. Recommended timeframes are 5m, 15m, 1h, 4h, and 1D. Default settings are optimized for QQQ. When applying to other instruments, the BB Length, StdDev Multiplier, and Bandwidth Percentile Window are the primary settings to adjust for the instrument's typical volatility profile.
________________________________________
The ATC Bollinger Band Percentile (ATC BBP) is a dual-layer oscillator that tells you two things simultaneously: where price sits inside its Bollinger envelope right now, and whether the current volatility environment is compressing, neutral, or expanding — measured against real historical data, not a hardcoded threshold.
Most Bollinger Band tools give you the bands. This one gives you the context behind the bands.
________________________________________
Who It's Built For
ATC BBP is designed for retail traders who already use Bollinger Bands or have tried them but found the raw %B reading too noisy or too vague to act on. If you've ever looked at a squeeze setup and wondered whether the bands were actually tight or just tighter than yesterday, this indicator was built to answer that question directly.
It works best for traders who use volatility as a filter before entering trend or breakout trades, want a cleaner and less reactive version of %B, or are building toward understanding normalized, statistically-grounded indicators.
________________________________________
Core Concept
Bollinger Bands place price in a dynamic envelope built from a moving average and standard deviation. The %B reading converts that envelope into a 0–100 scale: 100 means price is sitting on the upper band, 0 means price is on the lower band, and 50 means price is at the midpoint.
That's useful, but the raw reading is noisy and the bands themselves don't tell you whether they're wide or narrow relative to history. A band can look visually compressed on your chart and still be wider than it's been 75% of the time — or vice versa.
ATC BBP solves both problems. It smooths %B with a Hull Moving Average to reduce reactive noise, and it scores the current bandwidth as a percentile against a rolling window of its own history — so you always know objectively whether compression is real.
________________________________________
ATC Upgrades Over Standard %B
HMA Smoothing on %B The raw %B line reacts sharply to every candle. ATC BBP applies a Hull Moving Average to %B before it's plotted, cutting noise while preserving responsiveness. The raw %B is still available in the data window for comparison, but the smoothed version drives everything you see. You can adjust the smoothing length or disable it entirely.
Bandwidth Percentile Scoring This is the core ATC enhancement. Instead of asking "are the bands narrow?", ATC BBP asks "are the bands narrow relative to the last 125 bars of bandwidth history?" The bandwidth percentile is computed by ranking the current bandwidth against every value in the lookback window. A reading of 8% means the bands are tighter right now than they've been on 92% of recent bars. That's a real squeeze signal — not an eyeball call.
Empirical Zone Thresholds with Hysteresis The %B zone boundaries are not hardcoded round numbers. The defaults are set at empirically sensible levels and are fully adjustable. More importantly, every state transition — both the squeeze state and the %B zone — uses a configurable hysteresis band so the indicator doesn't flicker at the edges. Once a state is entered, it takes a meaningful move to exit it.
________________________________________
What's on the Chart
ATC BBP plots in a separate pane below your price chart.
The %B Line The smoothed %B oscillator on a 0–100 scale. The line changes color dynamically to reflect the current zone: green shades when price is in the lower portion of the bands, red shades in the upper portion, neutral grey for mid-range. When price tags or exceeds either band, the color deepens to full intensity. A fill between the %B line and the 50-level midline gives an immediate read on whether price is in the upper or lower half of the range.
Horizontal Reference Lines Five levels mark the key zones: lower extreme (0), lower quartile (20), midline (50), upper quartile (80), and upper extreme (100). Low-opacity colored background shading tints each zone — red above the upper quartile, green below the lower quartile, neutral in the middle.
Squeeze Pressure Bar Along the bottom of the pane, a colored bar marks the current squeeze state. Amber indicates a tight squeeze — bandwidth in the lowest percentile tier. Light yellow indicates a developing or loose squeeze. Blue indicates active volatility expansion. When no state is active, the bar disappears — the absence of color is meaningful. Diamond markers appear at the bar when a squeeze begins and again when expansion starts, so state transitions are never missed on a busy chart.
________________________________________
HUD Breakdown
The corner HUD (top right by default) gives you a live read of both indicator layers without having to inspect chart values:
Volatility — current squeeze state label: Tight Squeeze, Loose Squeeze, Expansion, or Neutral, color-coded to match the pressure bar
BW %-ile — the bandwidth percentile as a number, followed by a 10-block progress bar showing where current bandwidth sits on a visual scale from fully compressed to fully expanded
%B Zone — a text label for where price is in the envelope: Below Lower Band, Lower Quartile, Mid Range, Upper Quartile, or Above Upper Band
%B Reading — the smoothed %B value as a number
The HUD supports dark and light themes and can be repositioned to any corner of the pane.
________________________________________
Logic Layers
The indicator runs two independent state machines, each with its own hysteresis logic.
Squeeze State Machine Four states: Tight Squeeze (bandwidth percentile below the tight threshold), Loose Squeeze (between tight and loose thresholds), Neutral (mid-range bandwidth), and Expansion (above the expansion threshold). State transitions require the bandwidth percentile to move beyond the threshold by the hysteresis amount before the state flips. This prevents toggling at the boundary on marginal readings.
%B Zone State Machine Five zones tracking price location within the envelope: Below Lower Band, Lower Quartile, Mid Range, Upper Quartile, and Above Upper Band. The same hysteresis logic applies — once price enters a zone, it stays classified there until it moves decisively into the next zone.
The two machines run independently. You can be in a tight squeeze while price is in the upper quartile — which is a very different setup than a tight squeeze with price at the midline. The HUD shows both readings simultaneously so you always have the full picture.
________________________________________
Alerts
Seven alert conditions are built in.
BBP: Tight Squeeze Started — fires when the squeeze state first enters the tight tier. Use this to monitor compression setups across instruments before they break.
BBP: Tight Squeeze Released — fires when the tight squeeze breaks. This is the exit from compression, which may precede expansion or resolve back to neutral — both are meaningful.
BBP: Expansion Started — fires when bandwidth percentile crosses above the expansion threshold, confirming that volatility is breaking out of compression.
BBP: Price Above Upper Band — fires when %B reaches or exceeds 100, meaning price has tagged or broken through the upper band.
BBP: Price Below Lower Band — fires when %B reaches or falls below 0, meaning price has tagged or broken through the lower band.
BBP: %B Cross Above 50 — fires when smoothed %B crosses above the midline. Price location bias has shifted to the upper half of the envelope.
BBP: %B Cross Below 50 — fires when smoothed %B crosses below the midline. Price location bias has shifted to the lower half.
________________________________________
How to Trade With It
ATC BBP is a context indicator, not a signal generator. It tells you the volatility environment and price location so you can filter and frame your setups — it does not issue buy or sell signals on its own.
Step 1 — Check the Squeeze State First Before anything else, look at the HUD Volatility row and the pressure bar. Tight Squeeze means the market is coiling. Expansion means it's already moving. Neutral means neither is happening. This single read tells you what kind of market you're in before you look at anything else.
Step 2 — Use Squeeze Context to Filter Breakout Setups A tight squeeze is the setup condition for a potential expansion — it does not tell you which direction. When bandwidth is in the lowest 8–10 percentile of its history, start watching price action for the break, but wait for directional confirmation from your primary setup criteria before trading it. The squeeze tells you energy is building. Your edge tells you which way it breaks.
Step 3 — Use %B to Read Location Within the Setup Once you have a directional bias, %B tells you where price currently sits in the envelope. If you're looking for a long entry and %B is already above 80, price is extended toward the top of the range — it may be better to wait for a pullback toward the 50 midline. If %B is mid-range or lower quartile heading into a long setup, there's more room to run before hitting band resistance.
Step 4 — Look for Squeeze-Plus-Zone Confluence The highest-value reads come when both layers line up. A tight squeeze with %B at mid-range or lower quartile means compression is present and price has room to move higher if the break is bullish — watch for expansion to confirm with %B rising through 50. Expansion with %B crossing above 50 means volatility is moving and location bias is shifting bullish simultaneously — often the clearest confirmation that a breakout is real. Expansion with %B above 100 means price is already through the upper band in an expanding environment — valid in strong trends, a caution flag in range conditions.
Step 5 — Use Alerts for Multi-Instrument Monitoring If you're running ATC BBP across multiple instruments or timeframes, set the Tight Squeeze Started and Expansion Started alerts. These fire the moment a state changes so you're never watching the wrong chart while a setup develops elsewhere.
________________________________________
Settings Reference
Bollinger Bands BB Length (default 30) — period for the moving average and standard deviation calculation. Optimized default for QQQ. Increase for slower, more structural readings; decrease for more reactive readings on faster instruments.
BB StdDev Multiplier (default 1.6) — number of standard deviations for the band width. Optimized default for QQQ. Lower values tighten the bands and will increase the frequency of upper/lower extreme readings.
BB Source (default Close) — price source for the band calculation.
Smoothing %B HMA Smoothing (default 8) — Hull Moving Average length applied to %B. Set to 1 to disable smoothing and plot the raw %B line.
Squeeze Quality Bandwidth Percentile Window (default 125) — rolling lookback used to rank the current bandwidth. Larger windows produce more stable percentile readings against longer historical context.
Tight Squeeze Threshold (default 8) — bandwidth percentile below this level is classified as a tight squeeze.
Loose Squeeze Threshold (default 25) — bandwidth percentile between the tight threshold and this level is classified as a developing squeeze.
Expansion Threshold (default 75) — bandwidth percentile above this level is classified as active expansion.
State Hysteresis (default 3.0) — neutral band around each threshold. A state must be exceeded by this amount before the classification changes, preventing flicker on marginal readings.
%B Zones Upper Quartile (default 80) — %B above this is classified as Upper Quartile zone.
Lower Quartile (default 20) — %B below this is classified as Lower Quartile zone.
Upper Extreme (default 100) — %B at or above this is classified as Above Upper Band. Lower
Extreme (default 0) — %B at or below this is classified as Below Lower Band.
Visuals Shade %B Zones — toggles the background zone tinting on the oscillator pane. Show Squeeze Pressure Bar — toggles the colored state bar and diamond markers at the bottom of the pane. Color inputs for all states are fully adjustable if you prefer a different palette.
________________________________________
Recommended Instruments and Timeframes
ATC BBP is tested and validated on ES, NQ, CL, GC, SPY, QQQ, major equities, and major FX pairs. Recommended timeframes are 5m, 15m, 1h, 4h, and 1D. Default settings are optimized for QQQ. When applying to other instruments, the BB Length, StdDev Multiplier, and Bandwidth Percentile Window are the primary settings to adjust for the instrument's typical volatility profile.
________________________________________
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Visit AscendTradingConcepts.com for extensive FREE trading education and access to our Premium Exclusive Indicators.
Visit in your browser (Edge/Chrome/Safari) — TradingView's built-in browser does not support our site's latest security protocols.
Visit in your browser (Edge/Chrome/Safari) — TradingView's built-in browser does not support our site's latest security protocols.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Visit AscendTradingConcepts.com for extensive FREE trading education and access to our Premium Exclusive Indicators.
Visit in your browser (Edge/Chrome/Safari) — TradingView's built-in browser does not support our site's latest security protocols.
Visit in your browser (Edge/Chrome/Safari) — TradingView's built-in browser does not support our site's latest security protocols.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.