Unicorn Model Detector [AGPro Series]Unicorn Model Detector
Overview
The Unicorn Model Detector identifies one of the most discussed setups in Inner Circle Trader (ICT) and Smart Money Concepts literature: the Unicorn Model. A Unicorn forms when a Breaker Block and a Fair Value Gap (FVG) overlap inside the same price zone — a pocket where prior swing liquidity has been swept and an unfilled imbalance still exists at the retest. The detector scans for these overlaps, tracks every occurrence through its full lifecycle, and reports aggregate statistics in a compact on-chart panel. It is a detection and bookkeeping tool, not a trading strategy.
Unique Edge
Most breaker and FVG scripts publish either zones in isolation or require the user to eyeball the overlap. This detector does the overlap match automatically and only draws a zone when both conditions are present on the same chart area with the same directional bias. A strict causality rule is enforced — the Breaker must form first (after liquidity sweep) and the FVG must appear during or after the retest, which matches the true ICT Unicorn definition. A pairing that consumes a given breaker and FVG is removed from future candidate pools, so the chart never stacks redundant zones from the same source structure. A Loose overlap mode is also provided for users who prefer an ATR-based proximity interpretation instead of strict geometric intersection.
Methodology
1. Swing pivots are detected with a configurable left/right length using ta.pivothigh and ta.pivotlow.
2. When a confirmed pivot forms, the body range of the pivot bar is stored as the potential Breaker source zone.
3. A Breaker Block is registered when price closes through the previous-bar swing level in the opposite direction.
4. A Fair Value Gap is registered when a 3-bar formation produces an unfilled imbalance (low > high for bullish, high < low for bearish) and the gap exceeds a user-defined ATR multiple.
5. A Unicorn is spawned when a same-direction Breaker zone and FVG zone overlap vertically AND the FVG formed at or after the Breaker (causality check).
6. A configurable cooldown prevents consecutive spawns from clustering, improving signal hygiene.
7. The overlap rectangle becomes the tracked zone. Zone mid is the reference entry, the stop is placed 0.4 times the zone height beyond the structure boundary, and the target is projected at the user-defined R-multiple.
Signals & Alerts
Four independent alert conditions are exposed:
- New Unicorn Detected — a fresh bullish or bearish Unicorn has just formed.
- Unicorn Triggered — price has entered the overlap zone of a pending Unicorn.
- Target Hit — a triggered Unicorn has reached its R-multiple target.
- Stop Hit — a triggered Unicorn has been invalidated at its stop level.
All alerts fire once per bar close and include the ticker and timeframe in the payload.
Key Inputs
- Swing Pivot Length (default 7) — left/right length used for pivot confirmation.
- Breaker Lookback (default 80 bars) — maximum age for a broken swing to remain a valid Breaker.
- FVG Minimum Size (default 0.25 x ATR) — noise filter for 3-bar imbalances.
- Overlap Mode (Strict / Loose) — geometric intersection vs ATR-tolerance match.
- Reward-to-Risk Target (default 2.0) — multiple used to project the target level.
- Max Active Pending Unicorns (default 3) — chart-cleanliness cap.
- Cooldown After Signal (default 30 bars) — minimum spacing between consecutive spawns.
- Invalidate on Close Through Zone (default off) — optional tighter invalidation rule.
- Visual controls — show/hide per lifecycle state, label size, zone opacity, max recent labels.
- Panel controls — show/hide, location (6 positions), theme (Dark/Light), text size.
How to Use
1. Add the indicator to any timeframe; higher timeframes (1H, 4H, 1D) tend to produce structurally more meaningful Unicorns.
2. Watch for a new Unicorn zone to appear. Pending zones are drawn in the directional state color with a bold border; triggered ones switch to the indigo accent color; TP / SL / Expired zones fade to their respective colors with a thinner border.
3. Each zone carries a tethered flag label outside the price axis — Bullish labels below, Bearish labels above — so they never overlap candles.
4. The panel reports running counts of pending and active Unicorns, historical win rate, average R per setup, and total completed.
5. Use the displayed entry / target / stop reference lines as a structural map for your own analysis. The tool does not place orders and does not recommend position sizing.
6. Combine with higher-timeframe bias (trend, session context, HTF structure) before acting on any zone.
Limitations & Transparency
- The detector is a structural scanner, not a forecasting engine. It reports what has formed, not what will happen.
- Swing detection depends on pivot length; shorter lengths generate more noise, longer lengths miss smaller structures.
- Statistics are calculated on-chart from historical bars loaded by TradingView and will vary with timeframe, symbol and data range.
- Realtime behaviour: zones are drawn on confirmed events (bar close for breaks, 3-bar-complete for FVGs). Some invalidations are evaluated intrabar on wick touches of the stop level.
- The script is open-source under Mozilla Public License 2.0. Users are encouraged to inspect and adapt the methodology.
Risk Disclosure
This indicator is provided for educational and analytical purposes only. It is not financial advice, a trading signal service, or a strategy. Past structural patterns do not guarantee future outcomes. Trading involves substantial risk of loss; readers are solely responsible for their own decisions and risk management.
Pine Script® indicator






















