OPEN-SOURCE SCRIPT
Compression Vector [JOAT]

Compression Vector [JOAT]
Overview
Compression Vector is a dual-engine volatility compression detector built in Pine Script v6. It identifies moments when both Bollinger Band width and Average True Range simultaneously contract relative to their historical baselines — a confluence that institutional traders recognise as the calm before an explosive directional move. When the squeeze releases, the indicator fires scored breakout signals with adaptive ATR-based take-profit levels and stop-loss placement directly on the chart.

Why This Approach?
Most squeeze indicators rely on a single compression measure, such as BB width relative to Keltner Channel, which can produce false signals in low-volume sideways drift. Compression Vector cross-validates two independent compression engines:
- Engine 1 — ATR Historical Ratio: Compares the 14-bar ATR against a slow ATR of configurable length (default 50). If the ratio falls below the compression threshold, the first engine fires.
- Engine 2 — BB + ATR SMA Squeeze: Compares current BB width against its own SMA (so the band must narrow relative to its own recent average), AND compares the current ATR against its short-term SMA. Only when at least one of these secondary tests also confirms does a dual-engine squeeze register.
Both engines must agree before a zone is created. This eliminates the noise inherent in single-measure detectors.
Compression Zones — 3-Layer Institutional Box System
Each confirmed squeeze prints a three-layer box structure that visually encodes squeeze intensity through colour:
- Halo layer (outer): Wide, nearly transparent — marks the full expansion of the compressed range plus padding
- Body layer (mid): The actual high-to-low range of all bars inside the squeeze
- Core layer (inner): A tighter 40% interior slice highlighting the median energy pocket
The box colour progresses through a time-weighted palette: grey (< 5 bars), purple (5–9), teal (10–19), gold (20+). Longer squeezes accumulate more potential energy and are weighted accordingly in the signal score.
Breakout Signal Scoring (0–100)
When close breaks convincingly above or below a zone, the indicator computes a composite score before stamping the signal:
- Proximity score (up to 35) — volume vs. its 20-bar SMA
- Squeeze score (up to 35) — duration of the squeeze in bars × 2.5
- RSI score (up to 15) — directional RSI headroom (long: RSI below 62, short: RSI above 38)
- Impulse score (up to 15) — breakout candle body relative to ATR
Grade letter (A+, A, B, C, D) is stamped on the signal label. Only breakouts where the candle body exceeds a configurable ATR multiple ("Min Impulse Body") qualify.
Adaptive TP / SL Lines
Risk is calculated as the distance from entry to the opposite zone boundary plus an ATR buffer. Three take-profit levels at configurable R:R multiples (default 1.5R, 2.5R, 4.0R) are drawn as dotted lines extending forward 45 bars. The stop-loss line is drawn in the opposing colour at the calculated risk distance below/above entry.
Dashboard (Bottom Centre)
A compact 8-column table displays in real time:
- Squeeze state (COMPRESSING / RELAXED) with bar count
- ASCII compression gauge (6 segments)
- ATR ratio and BB width percentage
- RSI, volume multiplier, last zone score with grade
- Active zone count and warm-up status
Inputs Reference
Squeeze Engine
- ATR Historical Length (50) — lookback for the slow ATR baseline
- ATR Compression Threshold (0.72) — ratio below which ATR engine triggers
- Bollinger Band Length (20) — period for BB and BB-width SMA
- BB Std Dev Multiplier (2.0) — standard deviation width of the Bollinger Bands
- BB Width Squeeze Ratio (0.82) — fraction of BB-width SMA below which BB engine triggers
- ATR SMA Squeeze Ratio (0.90) — fraction of ATR SMA below which ATR secondary engine triggers
- Min Bars Required in Squeeze (3) — minimum consecutive bars before a zone is registered
Signal Filters
- Require Volume Above SMA — gates breakouts to above-average volume bars
- Volume SMA Length (20) — reference volume baseline
- Block Overbought/Oversold — RSI filter at 72 long / 28 short
- RSI Length (14)
- Min Impulse Body (1.3 ATR) — minimum breakout candle body in ATR units
- Max Zones Tracked (6)
Risk & Targets
- SL Buffer (0.3 ATR) — added to raw risk for stop placement
- TP1 / TP2 / TP3 R:R — take-profit multiples (1.5 / 2.5 / 4.0)
Visual Settings
- Show Compression Zones / Show TP-SL Lines / Show Dashboard
- Theme: Dark, Light, or Auto (detects chart background)
How to Use
1. Add the indicator on any liquid market and timeframe. A warmup of roughly 100 bars is required before signals appear.
2. Watch for the dashboard state to read COMPRESSING and the gauge to fill. The longer the squeeze, the higher the potential score on breakout.
3. Wait for a labelled signal (BREAK+ for long, BREAK- for short). Prefer grade A or A+.
4. Use the drawn TP lines for partial exits and the SL line for stop placement.
5. Higher timeframes (15m, 1H, 4H) tend to produce cleaner zones with fewer false breaks.
Non-Repainting Design
All signals are gated by barstate.isconfirmed, meaning they only fire on the final tick of a closed bar. Zones are computed from confirmed historical bars only. The indicator will never repaint a past signal.
Limitations
- In extremely choppy, low-volume markets, short squeezes (2–3 bars) may resolve without meaningful breakout momentum. Raise Min Bars to filter these.
- The composite score is calibrated for liquid instruments. Illiquid or exotic pairs may require adjustment of the volume multiplier filter.
- ATR-based TP/SL levels are approximate and should not replace proper position sizing.
- No future-bar lookahead is used in any request.security() call.
Disclaimer
This indicator is provided for educational and informational purposes only. Past performance of any signal pattern is not indicative of future results. Always use proper risk management and conduct your own analysis before making any trading decisions.
Made with passion by officialjackofalltrades
Overview
Compression Vector is a dual-engine volatility compression detector built in Pine Script v6. It identifies moments when both Bollinger Band width and Average True Range simultaneously contract relative to their historical baselines — a confluence that institutional traders recognise as the calm before an explosive directional move. When the squeeze releases, the indicator fires scored breakout signals with adaptive ATR-based take-profit levels and stop-loss placement directly on the chart.
Why This Approach?
Most squeeze indicators rely on a single compression measure, such as BB width relative to Keltner Channel, which can produce false signals in low-volume sideways drift. Compression Vector cross-validates two independent compression engines:
- Engine 1 — ATR Historical Ratio: Compares the 14-bar ATR against a slow ATR of configurable length (default 50). If the ratio falls below the compression threshold, the first engine fires.
- Engine 2 — BB + ATR SMA Squeeze: Compares current BB width against its own SMA (so the band must narrow relative to its own recent average), AND compares the current ATR against its short-term SMA. Only when at least one of these secondary tests also confirms does a dual-engine squeeze register.
Both engines must agree before a zone is created. This eliminates the noise inherent in single-measure detectors.
Compression Zones — 3-Layer Institutional Box System
Each confirmed squeeze prints a three-layer box structure that visually encodes squeeze intensity through colour:
- Halo layer (outer): Wide, nearly transparent — marks the full expansion of the compressed range plus padding
- Body layer (mid): The actual high-to-low range of all bars inside the squeeze
- Core layer (inner): A tighter 40% interior slice highlighting the median energy pocket
The box colour progresses through a time-weighted palette: grey (< 5 bars), purple (5–9), teal (10–19), gold (20+). Longer squeezes accumulate more potential energy and are weighted accordingly in the signal score.
Breakout Signal Scoring (0–100)
When close breaks convincingly above or below a zone, the indicator computes a composite score before stamping the signal:
- Proximity score (up to 35) — volume vs. its 20-bar SMA
- Squeeze score (up to 35) — duration of the squeeze in bars × 2.5
- RSI score (up to 15) — directional RSI headroom (long: RSI below 62, short: RSI above 38)
- Impulse score (up to 15) — breakout candle body relative to ATR
Grade letter (A+, A, B, C, D) is stamped on the signal label. Only breakouts where the candle body exceeds a configurable ATR multiple ("Min Impulse Body") qualify.
Adaptive TP / SL Lines
Risk is calculated as the distance from entry to the opposite zone boundary plus an ATR buffer. Three take-profit levels at configurable R:R multiples (default 1.5R, 2.5R, 4.0R) are drawn as dotted lines extending forward 45 bars. The stop-loss line is drawn in the opposing colour at the calculated risk distance below/above entry.
Dashboard (Bottom Centre)
A compact 8-column table displays in real time:
- Squeeze state (COMPRESSING / RELAXED) with bar count
- ASCII compression gauge (6 segments)
- ATR ratio and BB width percentage
- RSI, volume multiplier, last zone score with grade
- Active zone count and warm-up status
Inputs Reference
Squeeze Engine
- ATR Historical Length (50) — lookback for the slow ATR baseline
- ATR Compression Threshold (0.72) — ratio below which ATR engine triggers
- Bollinger Band Length (20) — period for BB and BB-width SMA
- BB Std Dev Multiplier (2.0) — standard deviation width of the Bollinger Bands
- BB Width Squeeze Ratio (0.82) — fraction of BB-width SMA below which BB engine triggers
- ATR SMA Squeeze Ratio (0.90) — fraction of ATR SMA below which ATR secondary engine triggers
- Min Bars Required in Squeeze (3) — minimum consecutive bars before a zone is registered
Signal Filters
- Require Volume Above SMA — gates breakouts to above-average volume bars
- Volume SMA Length (20) — reference volume baseline
- Block Overbought/Oversold — RSI filter at 72 long / 28 short
- RSI Length (14)
- Min Impulse Body (1.3 ATR) — minimum breakout candle body in ATR units
- Max Zones Tracked (6)
Risk & Targets
- SL Buffer (0.3 ATR) — added to raw risk for stop placement
- TP1 / TP2 / TP3 R:R — take-profit multiples (1.5 / 2.5 / 4.0)
Visual Settings
- Show Compression Zones / Show TP-SL Lines / Show Dashboard
- Theme: Dark, Light, or Auto (detects chart background)
How to Use
1. Add the indicator on any liquid market and timeframe. A warmup of roughly 100 bars is required before signals appear.
2. Watch for the dashboard state to read COMPRESSING and the gauge to fill. The longer the squeeze, the higher the potential score on breakout.
3. Wait for a labelled signal (BREAK+ for long, BREAK- for short). Prefer grade A or A+.
4. Use the drawn TP lines for partial exits and the SL line for stop placement.
5. Higher timeframes (15m, 1H, 4H) tend to produce cleaner zones with fewer false breaks.
Non-Repainting Design
All signals are gated by barstate.isconfirmed, meaning they only fire on the final tick of a closed bar. Zones are computed from confirmed historical bars only. The indicator will never repaint a past signal.
Limitations
- In extremely choppy, low-volume markets, short squeezes (2–3 bars) may resolve without meaningful breakout momentum. Raise Min Bars to filter these.
- The composite score is calibrated for liquid instruments. Illiquid or exotic pairs may require adjustment of the volume multiplier filter.
- ATR-based TP/SL levels are approximate and should not replace proper position sizing.
- No future-bar lookahead is used in any request.security() call.
Disclaimer
This indicator is provided for educational and informational purposes only. Past performance of any signal pattern is not indicative of future results. Always use proper risk management and conduct your own analysis before making any trading decisions.
Made with passion by officialjackofalltrades
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。