OPEN-SOURCE SCRIPT
Phantom Zone Visualizer (Auto-Mitigation)

SCRIPT OVERVIEW: "Phantom Zone Visualizer (Auto-Mitigation)"
This is a custom Pine Script v5 indicator designed to automatically detect, display, and manage Phantom-style supply and demand zones directly on your TradingView chart.
🎯 PURPOSE:
To visually identify high-probability institutional price zones using the Phantom model:
Impulse → Base → Impulse
Wick-to-body precision
Auto-deletion on mitigation
🧠 HOW IT WORKS (STEP BY STEP):
🔍 1. Impulse Detection
The script first checks if the current candle (bar 0) is part of a strong directional move (an impulse):
Impulse Up = large bullish candle (body > ATR * strength factor)
Impulse Down = large bearish candle
It uses the ATR (Average True Range) to confirm if the candle is large enough, based on a user-defined multiplier (default = 1.5× ATR).
🧱 2. Base Detection (1–3 small candles)
If an impulse is detected, the script checks previous candles (up to 3) to find a tight base:
Base = candles with small bodies (less than 60% of ATR)
These represent institutional order blocks
This follows Phantom’s rule:
"Two candles is institutional; four is confusion."
🧰 3. Zone Construction (Wick-to-Body)
Once a valid base is found, it constructs a Phantom zone box, using:
Demand Zones (bullish):
Bottom = lowest wick of base
Top = highest body open/close
Supply Zones (bearish):
Top = highest wick of base
Bottom = lowest body open/close
This creates a visual green (demand) or red (supply) box extending 10 candles forward.
🏷 4. Labeling
Each zone includes a label showing:
Zone type (SUPPLY or DEMAND)
Price top and bottom
Number of candles in the base
This helps visually verify the purity of the zone at a glance.
💣 5. Auto-Mitigation Logic
Every new candle checks if price has touched or entered any zone:
If price overlaps a zone (wick or body):
The script deletes the box
This follows Phantom's principle:
"Once touched, zone is mitigated and no longer valid"
This keeps your chart clean and disciplined, avoiding reused zones.
⚙️ SETTINGS:
Setting Purpose
Lookback How far to check for impulses
Impulse Strength Multiplier of ATR to define "big candle"
Max Base Candles Max # of base candles to consider (default = 3)
✅ WHAT THIS SCRIPT DOES WELL:
✅ Follows Phantom rulebook with precision
✅ Marks clean, institutional zones only
✅ Enforces discipline by auto-deleting mitigated zones
✅ Helps traders avoid overtrading used zones
✅ Simple to plug and use on any asset/timeframe
✅ Fast visual scanning of structure, base, and strength
🚫 WHAT IT DOES NOT DO (yet):
❌ No scoring system (Phantom Score out of 20)
❌ No risk:reward (RRR) projections
❌ No trend/timeframe alignment filters (HTF/ITF)
❌ No alerts for zone creation/mitigation
🧩 SUMMARY:
Your Phantom Zone Visualizer (Auto-Mitigation) is a strict, rule-based tool to:
✅ Identify valid Impulse → Base → Impulse formations
✅ Draw zones using Phantom wick-to-body logic
✅ Remove zones once they are mitigated
🧘 Keep your chart clean, your trading structured, and your focus sharp
This is a custom Pine Script v5 indicator designed to automatically detect, display, and manage Phantom-style supply and demand zones directly on your TradingView chart.
🎯 PURPOSE:
To visually identify high-probability institutional price zones using the Phantom model:
Impulse → Base → Impulse
Wick-to-body precision
Auto-deletion on mitigation
🧠 HOW IT WORKS (STEP BY STEP):
🔍 1. Impulse Detection
The script first checks if the current candle (bar 0) is part of a strong directional move (an impulse):
Impulse Up = large bullish candle (body > ATR * strength factor)
Impulse Down = large bearish candle
It uses the ATR (Average True Range) to confirm if the candle is large enough, based on a user-defined multiplier (default = 1.5× ATR).
🧱 2. Base Detection (1–3 small candles)
If an impulse is detected, the script checks previous candles (up to 3) to find a tight base:
Base = candles with small bodies (less than 60% of ATR)
These represent institutional order blocks
This follows Phantom’s rule:
"Two candles is institutional; four is confusion."
🧰 3. Zone Construction (Wick-to-Body)
Once a valid base is found, it constructs a Phantom zone box, using:
Demand Zones (bullish):
Bottom = lowest wick of base
Top = highest body open/close
Supply Zones (bearish):
Top = highest wick of base
Bottom = lowest body open/close
This creates a visual green (demand) or red (supply) box extending 10 candles forward.
🏷 4. Labeling
Each zone includes a label showing:
Zone type (SUPPLY or DEMAND)
Price top and bottom
Number of candles in the base
This helps visually verify the purity of the zone at a glance.
💣 5. Auto-Mitigation Logic
Every new candle checks if price has touched or entered any zone:
If price overlaps a zone (wick or body):
The script deletes the box
This follows Phantom's principle:
"Once touched, zone is mitigated and no longer valid"
This keeps your chart clean and disciplined, avoiding reused zones.
⚙️ SETTINGS:
Setting Purpose
Lookback How far to check for impulses
Impulse Strength Multiplier of ATR to define "big candle"
Max Base Candles Max # of base candles to consider (default = 3)
✅ WHAT THIS SCRIPT DOES WELL:
✅ Follows Phantom rulebook with precision
✅ Marks clean, institutional zones only
✅ Enforces discipline by auto-deleting mitigated zones
✅ Helps traders avoid overtrading used zones
✅ Simple to plug and use on any asset/timeframe
✅ Fast visual scanning of structure, base, and strength
🚫 WHAT IT DOES NOT DO (yet):
❌ No scoring system (Phantom Score out of 20)
❌ No risk:reward (RRR) projections
❌ No trend/timeframe alignment filters (HTF/ITF)
❌ No alerts for zone creation/mitigation
🧩 SUMMARY:
Your Phantom Zone Visualizer (Auto-Mitigation) is a strict, rule-based tool to:
✅ Identify valid Impulse → Base → Impulse formations
✅ Draw zones using Phantom wick-to-body logic
✅ Remove zones once they are mitigated
🧘 Keep your chart clean, your trading structured, and your focus sharp
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。