Adaptive Squeeze Memory [PhenLabs]🚀 #66 Adaptive Squeeze Memory
📌 Overview
Adaptive Squeeze Memory turns a standard public-domain BB/KC squeeze into a clear “what happened after similar squeezes?” dashboard. Instead of forcing traders to decode a complex probability model, ASM gives a simple setup read first: Long Breakout Watch, Short Breakdown Watch, Lean Long, Lean Short, Two-Way Volatility, or Building Memory.
Behind that simple read, ASM compares the current squeeze event against prior confirmed squeezes with similar volatility, RSI, and volume conditions, then projects the historical distribution of forward returns as a cone.
This is an original public-concept interpretation built from standard market primitives: Bollinger Band width, Keltner Channel width, ATR, RSI, volume ratio, Euclidean similarity scoring, and nearest-rank percentiles. It does not copy, clone, reproduce, deobfuscate, or attempt to recreate any commercial squeeze, memory, or prediction product.
📊 What Makes It Different
Most squeeze tools answer one question: “Is price compressed?” Adaptive Squeeze Memory asks a sharper and more tradable question: “When the market has compressed like this before, did the forward memory favor an upside breakout, a downside breakdown, or volatility expansion without a clean directional edge?”
The result is a cleaner TradingView experience: a plain-English memory dashboard for fast interpretation, plus a projected return cone for traders who want the deeper statistical context.
🚀 Core Features
✅ Public-domain BB/KC squeeze detection using Bollinger Band width versus Keltner Channel width
✅ Similarity memory engine using normalized ATR, RSI, and volume ratio
✅ Configurable nearest-match count for comparing the current squeeze against prior events
✅ 1-bar, 3-bar, 5-bar, and 10-bar forward return distributions
✅ Median projection plus optional 25th/75th and 10th/90th percentile bands
✅ Memory Dashboard with setup state, median edge, likely range, bullish probability, score, matches, and next-step guidance
✅ Memory Bias Score from -100 to +100 for fast data-window scanning
✅ Long Breakout Watch and Short Breakdown Watch markers for stronger memory skews
✅ Confirmed-bar only logic with no request.security() and no lookahead
✅ Capped projection-line arrays for stable long-chart performance
🔧 Settings
Squeeze Memory Lookback
Default: 252
Range: 50–2000
Description: Maximum number of mature prior squeeze events retained for similarity matching.
Similarity Match Count
Default: 10
Range: 3–50
Description: Number of closest historical squeeze events used to build the probability cone.
Cone Projection Bars
Default: 10
Range: 10–50
Description: Forward visual projection window. The statistical anchors are 1, 3, 5, and 10 bars.
BB Length / BB Multiplier
Default: 20 / 2.0
Range: Length 5–200, Multiplier 0.5–5.0
Description: Bollinger Band settings used to measure compression.
KC Length / KC Multiplier
Default: 20 / 1.5
Range: Length 5–200, Multiplier 0.5–5.0
Description: Keltner Channel settings used as the volatility envelope comparison.
ATR Length
Default: 14
Range: 2–200
Description: ATR input for the normalized volatility feature.
RSI Length
Default: 14
Range: 2–200
Description: RSI input for the momentum-position feature.
Volume MA Length
Default: 50
Range: 5–300
Description: Moving average baseline for the relative volume feature.
Similarity Weight: ATR / RSI / Volume
Default: 1.0 / 1.0 / 1.0
Range: 0.0–5.0
Description: Controls how strongly each feature influences the Euclidean distance score.
Bull Cone Color / Bear Cone Color
Default: Lime / Red
Range: Any TradingView color
Description: Sets the projection color based on whether the 10-bar median return is positive or negative.
Show Percentile Bands
Default: On
Range: On/Off
Description: Toggles the inner 25th/75th percentile and outer 10th/90th percentile cone paths.
Show Memory Dashboard
Default: On
Range: On/Off
Description: Displays the simplified readout so users do not need to interpret the full cone manually.
Median Edge Threshold %
Default: 0.20
Range: 0.05–5.0
Description: Minimum median 10-bar edge required before ASM can classify a strong directional watch.
Directional Probability Threshold %
Default: 55
Range: 50–80
Description: Minimum matched-outcome probability required before ASM classifies a strong long or short watch.
🔥 How It Works
1. Detect compression
• ASM compares Bollinger Band width against Keltner Channel width.
• A squeeze event fires only when compression begins on a confirmed bar.
2. Capture the squeeze fingerprint
• Each confirmed squeeze stores normalized ATR, RSI, and relative volume.
• Events are stored in flat parallel arrays for Pine v6 compatibility.
3. Let history mature naturally
• Forward returns are filled only after the 1st, 3rd, 5th, and 10th future bars have actually printed.
• No future data is read early, and no request.security() calls are used.
4. Match the current event to memory
• The current squeeze is compared against mature prior squeezes.
• Weighted Euclidean distance ranks the most similar historical events.
• The closest N matches form the statistical sample.
5. Convert the distribution into a simple read
• Long Breakout Watch appears when the median edge and bullish outcome probability both clear their thresholds.
• Short Breakdown Watch appears when the median edge and bearish outcome probability both clear their thresholds.
• Lean Long and Lean Short appear when the sample has directional skew but not enough strength for a full watch.
• Two-Way Volatility appears when the historical memory favors expansion but not a clean direction.
6. Project the probability cone
• ASM computes nearest-rank percentiles of the matched forward returns.
• Median, 25th/75th, and 10th/90th percentile paths are drawn forward from the current squeeze bar.
🎨 Visual Guide
• Solid path: median projected forward return
• Dashed paths: 25th and 75th percentile range
• Dotted paths: 10th and 90th percentile range
• Column plot: latest 10-bar median memory edge
• Dashboard: plain-English setup state, range, bullish probability, score, matches, and next-step guidance
• LONG / SHORT markers: stronger confirmed directional memory events
• Yellow marker: confirmed squeeze-memory event
📖 Best Used For
Adaptive Squeeze Memory is designed for traders who want context around volatility compression. It is especially useful for crypto, indices, liquid equities, and FX pairs where squeeze events repeat often enough to build a meaningful memory sample.
✅ Notes
• Pine Script v6 indicator
• Separate pane output
• Confirmed-bar only
• No external data
• No request.security()
• No lookahead
• No commercial/proprietary logic
⚠️ Limitations
ASM is a statistical context tool, not a prediction engine. Percentile cones summarize what similar prior squeezes did; they do not guarantee what the current squeeze will do. Early charts or rare symbols may have too few mature matches for a useful cone until enough events accumulate.
Pine Script® indicator






















