OPEN-SOURCE SCRIPT
Squeeze AI - Breakout Direction Probability [Dots3Red]

🗜️ SQUEEZE AI - BREAKOUT DIRECTION PROBABILITY [Dots3Red]
A squeeze tells you volatility is loading. It has never told you which way it's going to release. This script fixes that second half of the problem - not by predicting the future, but by remembering the past. Every completed squeeze on your chart becomes a measured data point, and when a new squeeze fires, the script reports what the most similar past squeezes actually did.
✨ WHY THIS MATTERS
Bollinger-inside-Keltner squeeze detection has existed for years, and every version of it does the same thing: flags that a squeeze is happening, then flags that it released. What happens next has always been left to the trader's judgment.
This script keeps score instead. It records the character of every squeeze that completes — how long it ran, how tight it got, what volume and momentum looked like — and pairs that with what price genuinely did afterward. When the next squeeze fires, it doesn't guess; it looks up the most similar squeezes this chart has actually produced and reports their real outcomes.
📊 ▲ 68% | +2.1 ATR | N=34
That reads as: of the 34 most similar past squeezes on this chart, 68% broke upward, averaging a 2.1 ATR move. Measured history, not a formula assuming squeezes behave a certain way.
⚙️ HOW IT WORKS
🗜️ Squeeze detection — the standard definition: Bollinger Bands (mean ± standard deviation) compress fully inside Keltner Channels (mean ± ATR). The moment BB's upper band drops below KC's upper band and BB's lower band rises above KC's lower band, a squeeze is active. A minimum-duration filter discards brief compressions too short to carry real information.
📐 Compression depth — beyond simple on/off, the script tracks how tight the squeeze actually gets: 0% means BB has barely tucked inside KC, approaching 100% means BB has nearly collapsed to a point. This becomes one of the features used for matching, since a shallow squeeze and an extreme one are genuinely different situations.
🧠 The KNN engine — every completed squeeze is stored as five measurements: duration, compression depth, average volume behavior during the squeeze, momentum at release, and volatility context. When it resolves, the actual outcome — direction and distance in ATR — is recorded against those five measurements. A new squeeze is compared against this stored history, and the K most similar past squeezes vote on direction and expected distance.
🔮 Live anticipation — while a squeeze is still compressing, before it even releases, an optional live label shows the KNN's current lean based on the squeeze's characteristics so far. This updates as the compression develops, so you're not waiting for the release to get a read.
🔒 Non-repainting — squeeze tracking, firing, and outcome grading all happen only on confirmed bars. The live anticipation label is explicitly a live-state readout (clearly distinguished from the historical fire labels) and is deleted and redrawn each update rather than left as a permanent mark.
🧭 HOW TO USE
1️⃣ Wait for the sample count. Early on a fresh chart, fire labels will show "Training… (4/12)" instead of a probability. The engine needs a real base of completed squeezes before its reads mean anything — don't trust a probability built on a handful of samples.
2️⃣ Read the N, not just the percentage. "▲ 68% | N=34" is a meaningfully different statement than "▲ 68% | N=8" — the first is a real pattern, the second could easily be noise. The script always shows N specifically so you can judge that yourself.
3️⃣ Watch the live anticipation label as the squeeze develops. A squeeze's characteristics (duration, compression, volume) can shift the KNN lean while it's still compressing — the live label lets you see that lean forming before release, not just after.
4️⃣ Check the dashboard's global stat for chart-level context. Beyond any single squeeze, the dashboard tracks what percentage of every recorded squeeze on this chart broke upward overall — useful context for whether this instrument has had a directional bias in its squeeze behavior.
5️⃣ Tune the minimum squeeze duration to the timeframe. A 4-bar minimum on a daily chart and a 4-bar minimum on a 1-minute chart represent very different amounts of real compression — adjust it to the timeframe you're actually trading.
🛠️ SETTINGS
🗜️ Squeeze Detection
• BB Length / Multiplier, KC Length / Multiplier — standard Bollinger and Keltner parameters
• Min Squeeze Duration — shortest compression the script will bother recording
📊 KNN Engine
• Outcome Window — bars after release over which direction and distance are measured
• K Neighbors — how many similar past squeezes vote on the current one
• Max / Min Training Samples — memory cap and the minimum before probabilities display
• ATR Baseline Period — the volatility-context window used in matching
🎨 Visualization
• Fill between BB — boolean to control area fill
• Squeeze Background Tint, Squeeze Zone Box — two independent ways to mark the active compression, usable together or separately
• Fire Labels with Probability — the KNN readout shown on release
• Live Anticipation Label — the developing-squeeze readout described above
🖥️ Dashboard
• Show/hide, position — current squeeze state and duration, compression %, live KNN read, and chart-wide sample totals
EXAMPLE (area fill between BB bands)
📝 NOTES
Squeeze frequency varies enormously by instrument and timeframe — a fast-moving asset will accumulate the sample count needed for meaningful probabilities much faster than a slow one. On a new chart, expect several squeezes to pass before the KNN read becomes genuinely informative rather than a placeholder.
⚠️ DISCLAIMER
This is an analytical and visualization tool. It does not generate trade signals and does not constitute financial advice. Historical squeeze outcomes do not guarantee how any future squeeze will resolve.
A squeeze tells you volatility is loading. It has never told you which way it's going to release. This script fixes that second half of the problem - not by predicting the future, but by remembering the past. Every completed squeeze on your chart becomes a measured data point, and when a new squeeze fires, the script reports what the most similar past squeezes actually did.
✨ WHY THIS MATTERS
Bollinger-inside-Keltner squeeze detection has existed for years, and every version of it does the same thing: flags that a squeeze is happening, then flags that it released. What happens next has always been left to the trader's judgment.
This script keeps score instead. It records the character of every squeeze that completes — how long it ran, how tight it got, what volume and momentum looked like — and pairs that with what price genuinely did afterward. When the next squeeze fires, it doesn't guess; it looks up the most similar squeezes this chart has actually produced and reports their real outcomes.
📊 ▲ 68% | +2.1 ATR | N=34
That reads as: of the 34 most similar past squeezes on this chart, 68% broke upward, averaging a 2.1 ATR move. Measured history, not a formula assuming squeezes behave a certain way.
⚙️ HOW IT WORKS
🗜️ Squeeze detection — the standard definition: Bollinger Bands (mean ± standard deviation) compress fully inside Keltner Channels (mean ± ATR). The moment BB's upper band drops below KC's upper band and BB's lower band rises above KC's lower band, a squeeze is active. A minimum-duration filter discards brief compressions too short to carry real information.
📐 Compression depth — beyond simple on/off, the script tracks how tight the squeeze actually gets: 0% means BB has barely tucked inside KC, approaching 100% means BB has nearly collapsed to a point. This becomes one of the features used for matching, since a shallow squeeze and an extreme one are genuinely different situations.
🧠 The KNN engine — every completed squeeze is stored as five measurements: duration, compression depth, average volume behavior during the squeeze, momentum at release, and volatility context. When it resolves, the actual outcome — direction and distance in ATR — is recorded against those five measurements. A new squeeze is compared against this stored history, and the K most similar past squeezes vote on direction and expected distance.
🔮 Live anticipation — while a squeeze is still compressing, before it even releases, an optional live label shows the KNN's current lean based on the squeeze's characteristics so far. This updates as the compression develops, so you're not waiting for the release to get a read.
🔒 Non-repainting — squeeze tracking, firing, and outcome grading all happen only on confirmed bars. The live anticipation label is explicitly a live-state readout (clearly distinguished from the historical fire labels) and is deleted and redrawn each update rather than left as a permanent mark.
🧭 HOW TO USE
1️⃣ Wait for the sample count. Early on a fresh chart, fire labels will show "Training… (4/12)" instead of a probability. The engine needs a real base of completed squeezes before its reads mean anything — don't trust a probability built on a handful of samples.
2️⃣ Read the N, not just the percentage. "▲ 68% | N=34" is a meaningfully different statement than "▲ 68% | N=8" — the first is a real pattern, the second could easily be noise. The script always shows N specifically so you can judge that yourself.
3️⃣ Watch the live anticipation label as the squeeze develops. A squeeze's characteristics (duration, compression, volume) can shift the KNN lean while it's still compressing — the live label lets you see that lean forming before release, not just after.
4️⃣ Check the dashboard's global stat for chart-level context. Beyond any single squeeze, the dashboard tracks what percentage of every recorded squeeze on this chart broke upward overall — useful context for whether this instrument has had a directional bias in its squeeze behavior.
5️⃣ Tune the minimum squeeze duration to the timeframe. A 4-bar minimum on a daily chart and a 4-bar minimum on a 1-minute chart represent very different amounts of real compression — adjust it to the timeframe you're actually trading.
🛠️ SETTINGS
🗜️ Squeeze Detection
• BB Length / Multiplier, KC Length / Multiplier — standard Bollinger and Keltner parameters
• Min Squeeze Duration — shortest compression the script will bother recording
📊 KNN Engine
• Outcome Window — bars after release over which direction and distance are measured
• K Neighbors — how many similar past squeezes vote on the current one
• Max / Min Training Samples — memory cap and the minimum before probabilities display
• ATR Baseline Period — the volatility-context window used in matching
🎨 Visualization
• Fill between BB — boolean to control area fill
• Squeeze Background Tint, Squeeze Zone Box — two independent ways to mark the active compression, usable together or separately
• Fire Labels with Probability — the KNN readout shown on release
• Live Anticipation Label — the developing-squeeze readout described above
🖥️ Dashboard
• Show/hide, position — current squeeze state and duration, compression %, live KNN read, and chart-wide sample totals
EXAMPLE (area fill between BB bands)
📝 NOTES
Squeeze frequency varies enormously by instrument and timeframe — a fast-moving asset will accumulate the sample count needed for meaningful probabilities much faster than a slow one. On a new chart, expect several squeezes to pass before the KNN read becomes genuinely informative rather than a placeholder.
⚠️ DISCLAIMER
This is an analytical and visualization tool. It does not generate trade signals and does not constitute financial advice. Historical squeeze outcomes do not guarantee how any future squeeze will resolve.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
Connect the dots to elevate your trading.
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
Connect the dots to elevate your trading.
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。