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
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.