OPEN-SOURCE SCRIPT

FVG Sweep Magnet Engine [PhenLabs]

3 201
📊 FVG Sweep Magnet Engine [PhenLabs]

Version: PineScript™ v6

📌 Description
The FVG Sweep Magnet Engine turns displacement-born Fair Value Gaps into scored magnetic targets that only arm after a real liquidity sweep. Instead of treating every imbalance as tradeable, FSME waits for buy-side or sell-side liquidity to be raided, then confirms when price is pulled back into a high-quality FVG.

This solves the two biggest failure modes retail ICT tools create: trading empty gaps with no context, and chasing sweeps that never reclaim structure. Neon multi-layer magnet beams, graded gap boxes, and a live regime dashboard make the confluence readable in one glance — built for dark-chart screenshots and fast decision-making on futures, indices, FX, and crypto.

🚀 Points of Innovation
  • Displacement-validated FVG detection filters out micro-noise gaps that never attract price
  • Liquidity sweep gate (BSL/SSL raid + rejection) must print before any magnet signal arms
  • 0–10 quality score blends gap size, displacement strength, freshness, and volume impulse
  • Clean visual hierarchy: soft FVG zones + single CE midline by default; neon only on MAG
  • Partial-fill fade and full mitigation cleanup keep the chart honest as gaps get consumed
  • Live FSME dashboard tracks bias, live gaps, best score, sweep state, and last signal


🔧 Core Components
  • Displacement FVG Engine: Detects classic 3-candle bullish/bearish imbalances only when the middle candle body clears an ATR displacement threshold and the gap clears a minimum ATR size filter
  • Liquidity Rail Tracker: Maintains confirmed swing BSL/SSL pools as dotted rails and classifies wick-rejection raids that reclaim the level
  • Magnet Confluence Gate: Arms a signal only when a fresh sweep window overlaps a live scored FVG that price re-enters with directional close confirmation
  • Target Projector: Extends dotted neon target rays from the FVG midline by ATR multiple after a magnet print
  • Regime Dashboard: Compact top-right table summarizing bull/bear FVG count, best score, sweep state, last signal, nearest magnet mid, and ATR


🔥 Key Features
  • Non-repaint pivot liquidity and confirmed-bar FVG logic suitable for alerts and live trading
  • Configurable displacement, gap size, magnet window, min score, and target extension
  • Bull cyan / bear magenta neon palette with independent fill, border, rail, and beam colors
  • Optional faded mitigated FVGs for study mode, or hard-delete cleanup for clean charts
  • Alertconditions for bull/bear magnets, BSL/SSL sweeps, and new displacement FVGs
  • Works as a standalone SMC overlay or confluence layer on top of session/order-block tools


🎨 Visualization
  • FVG zones: Soft teal/red translucent boxes (high transparency so candles stay readable) with score on the right edge
  • CE midline: Single thin dashed line at the gap center — no permanent multi-layer beam cage
  • Neon on MAG only: Triple glow beam + TP ray appear only when a magnet signal arms
  • MAG labels: Clear ▲ MAG / ▼ MAG tags offset above/below the bar (not stacked on wicks)
  • Optional extras (off by default): liquidity rails and sweep diamonds for power users
  • Signal highlight: Soft bar tint only on confirmed MAG bars
  • Dashboard: Compact 6-row panel — Bias, Live Gaps, Best Score, Sweep, Last Signal


📖 Usage Guidelines
  • Max Active FVGs — Default: 10 — Range: 2-40 — Keep low for a clean chart
  • Displacement ATR Mult — Default: 1.25 — Range: 0.3-5.0 — Raise on noisy lower TFs
  • Min Gap Size (ATR) — Default: 0.25 — Range: 0.05-3.0 — Higher = fewer, cleaner zones
  • Require Displacement Candle — Default: true — Keep on for quality
  • Max FVG Age (bars) — Default: 60 — Range: 10-300 — Expires stale magnets
  • Magnet Window — Default: 18 — Range: 3-80 — Bars after a sweep for FVG entry confirm
  • Min Score for Signal — Default: 5 — Range: 0-10 — Raise to 7+ for selective setups
  • Show FVG Midline (CE) — Default: true — Single dashed CE line per zone
  • Neon Beam Only on MAG — Default: true — Neon appears only on confirmed signals
  • Show Liquidity Rails — Default: false — Optional; off keeps chart readable
  • Show Sweep Diamonds — Default: false — Optional; off by default to reduce noise


✅ Best Use Cases
  • ICT/SMC traders waiting for liquidity raids into unfilled FVGs instead of blind gap fades
  • Intraday index and futures traders (ES, NQ, YM) on 1m–15m seeking clean reversal confluence
  • FX and crypto traders mapping displacement legs during London/NY expansion
  • Prop-style discretionary traders who want scored setups with explicit invalidation (full gap fill)
  • Content creators capturing high-contrast neon dark-chart screenshots for TradingView publish art


⚠️ Limitations
  • FVG detection is geometric (3-candle imbalance) and does not use true order-book data
  • Sweep logic uses confirmed swing pivots, so very fresh local highs/lows need pivot length bars to register
  • High-volatility news spikes can create large displacement gaps that score well but fail if context is one-way trend
  • Neon beams and boxes are object-limited; extreme settings (max FVGs + long age) can hit TradingView object caps
  • This is a confluence overlay, not a complete strategy — always pair with risk rules and higher-timeframe bias


💡 What Makes This Unique
  • Sweep-gated magnets: FVGs stay passive until liquidity is actually raided — reverse of “every gap is a signal” tools
  • Scored gaps: Traders see why a zone matters (size, displacement, age, volume) instead of binary boxes
  • Signal-first visuals: zones stay quiet until confluence arms — neon and TP only on MAG
  • PhenLabs DNA: Liquidity + engine naming + dashboard, fused with this week’s dominant FVG/ICT community demand


🔬 How It Works
  1. Displacement scan: On each bar the engine checks for a 3-candle bullish or bearish FVG, requires the middle candle body to clear ATR × displacement mult, and rejects gaps smaller than ATR × min gap size
  2. Score + draw: Qualifying gaps receive a 0–10 score and are rendered as translucent boxes with a three-layer neon midline beam and optional score label
  3. Liquidity map: Confirmed pivot highs/lows become BSL/SSL rails; a sweep prints when price raids the level with sufficient wick and closes back through it
  4. Magnet arming: For a limited bar window after the sweep, if price re-enters a live same-direction FVG that clears the min score and closes in the reclaim direction, a MAG signal fires
  5. Projection + lifecycle: Dotted ATR targets extend from the magnet mid; partial fills fade the box, full fills or max age invalidate the gap and clean objects unless faded mode is enabled

💡 Note:
Use FSME as a visual decision-support layer for liquidity-to-imbalance workflows. Confirm higher-timeframe bias, define risk beyond the opposite side of the FVG or swept pool, and never treat magnet markers as guaranteed entries. This script is an analytical aid only and does not constitute financial advice.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.