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提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。