OPEN-SOURCE SCRIPT
ICT Fair Value Gap Detector [Eˣ]

⚡ Fair Value Gap Detector
Overview
The Fair Value Gap Detector automatically identifies price imbalances on your charts - the inefficiencies left behind when price moves too quickly. This indicator reveals where price is likely to return for "rebalancing", based on ICT (Inner Circle Trader) concepts of market efficiency.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 What This Indicator Does
Detects Fair Value Gaps:
• 🟢 Bullish FVG - Gap left below during aggressive upward move
• 🔴 Bearish FVG - Gap left above during aggressive downward move
• Automatically identifies 3-candle price inefficiencies
• Works on all timeframes and instruments
Smart Fill Tracking:
• Full Fill - Price completely fills the gap
• 50% Fill - Price fills half the gap (critical level)
• Partial Fill - Price touches gap edge
• Real-time fill percentage tracking
• Auto-removes filled gaps (optional)
Professional Features:
• Active Gap Highlighting - Shows nearest unfilled gap
• Distance Calculator - Displays how far price is from gaps
• Market Bias - Analysis based on gap balance
• Size Filtering - Minimum gap size to avoid noise
• Visual Clarity - Clean boxes with color-coding
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📚 Understanding Fair Value Gaps
What Are Fair Value Gaps?
Fair Value Gaps (FVGs), also known as imbalances or inefficiencies, are zones where price moved so quickly that normal trading didn't occur. They represent:
• Price Imbalance - One-sided aggressive buying or selling
• Unfair Pricing - Some participants didn't get to trade at these levels
• Market Inefficiency - Supply/demand equilibrium was disrupted
• Rebalancing Zones - Price often returns to "fill" these gaps
The ICT Concept:
Markets constantly seek equilibrium (fair value). When price moves too fast:
1. It leaves gaps where normal trading didn't happen
2. These gaps represent unfair/inefficient pricing
3. Market has a tendency to return and "rebalance"
4. Smart money knows this and trades the fills
Why FVGs Work:
• Unfilled Orders - Traders who missed the move have pending orders in the gap
• Algorithmic Trading - Algos programmed to exploit inefficiencies
• Market Psychology - Traders notice gaps and place orders there
• Institutional Behavior - Smart money uses gaps for entries/exits
FVG vs Regular Gaps:
• Regular Gaps - Occur at market open, between daily closes
• Fair Value Gaps - Occur intraday, between 3 consecutive candles
• FVGs happen more frequently and on all timeframes
• FVGs are more tradeable for intraday/swing traders
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🟢 Bullish Fair Value Gaps Explained
How They Form:
Bullish FVG requires 3 candles:
1. Candle 1 - Any candle (sets the high reference)
2. Candle 2 - Strong bullish candle (aggressive buying)
3. Candle 3 - Continuation candle
The Gap: Candle 3's LOW is above Candle 1's HIGH = Gap left unfilled
Visual Example:
```
Candle 3: Low at $105 ──────────┐
│ ← GAP (Bullish FVG)
Candle 2: Strong bullish │
│
Candle 1: High at $100 ──────────┘
```
What It Means:
• Price jumped from $100 to $105+ so fast, no trading occurred in between
• This $100-$105 zone is "unfair" - buyers/sellers didn't get to trade there
• Market may return to this zone to "rebalance"
• When price returns, it often acts as support
Trading Bullish FVGs:
Strategy:
• Wait for price to retrace down into the bullish FVG (green box)
• Look for rejection/bounce from the gap zone
• Enter long when price respects the FVG as support
• Stop loss: Below the FVG
• Target: Previous high or opposite FVG
Best Entry Points:
• 50% Fill: Price enters middle of gap (highest probability)
• Full Fill: Price touches bottom of gap (aggressive entry)
• Tap & Reject: Price quickly enters and exits gap (strong signal)
Example Trade:
• Bullish FVG forms: $50,000 - $50,500 (500 point gap)
• Price rallies to $52,000 then retraces
• Price drops to $50,250 (50% of gap filled)
• Bullish reversal candle appears
• Enter long at $50,500, stop at $49,800
• Target: $52,000+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔴 Bearish Fair Value Gaps Explained
How They Form:
Bearish FVG requires 3 candles:
1. Candle 1 - Any candle (sets the low reference)
2. Candle 2 - Strong bearish candle (aggressive selling)
3. Candle 3 - Continuation candle
The Gap: Candle 3's HIGH is below Candle 1's LOW = Gap left unfilled
Visual Example:
```
Candle 1: Low at $100 ───────────┐
│ ← GAP (Bearish FVG)
Candle 2: Strong bearish │
│
Candle 3: High at $95 ───────────┘
```
What It Means:
• Price dropped from $100 to $95 so fast, no trading occurred in between
• This $95-$100 zone is "unfair" - buyers/sellers didn't get to trade there
• Market may return to this zone to "rebalance"
• When price returns, it often acts as resistance
Trading Bearish FVGs:
Strategy:
• Wait for price to retrace up into the bearish FVG (red box)
• Look for rejection/reversal from the gap zone
• Enter short when price respects the FVG as resistance
• Stop loss: Above the FVG
• Target: Previous low or opposite FVG
Best Entry Points:
• 50% Fill: Price enters middle of gap (highest probability)
• Full Fill: Price touches top of gap (aggressive entry)
• Tap & Reject: Price quickly enters and exits gap (strong signal)
Example Trade:
• Bearish FVG forms: $48,000 - $48,500 (500 point gap)
• Price drops to $46,000 then retraces
• Price rallies to $48,250 (50% of gap filled)
• Bearish reversal candle appears
• Enter short at $48,000, stop at $48,700
• Target: $46,000-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 How To Use This Indicator
Strategy 1: FVG Rebalancing (Classic)
Best For: Swing trading, reversal trading
Timeframes: 15min, 1H, 4H
Win Rate: 65-75%
Entry Rules:
1. Identify unfilled FVG (bright color, not gray)
2. Wait for price to return to the gap
3. Best entry: 50% fill of the gap
4. Look for reversal confirmation:
• Bullish FVG: Pin bar, engulfing, hammer
• Bearish FVG: Shooting star, bearish engulfing
5. Enter when price bounces/rejects from FVG
6. Stop: Beyond opposite side of FVG
7. Target: 2-3R or previous high/low
Why It Works: 70%+ of FVGs get filled, and 60%+ show reaction
Strategy 2: FVG + Order Block Confluence
Best For: High-probability setups
Timeframes: 1H, 4H
Win Rate: 75-85%
Entry Rules:
1. Find FVG that overlaps with Order Block
2. This creates a "super zone" of confluence
3. Wait for price to return to this zone
4. Enter on first touch of confluence zone
5. Stop: Beyond the confluence zone
6. Target: 3-4R
Why It Works: Double institutional concepts = highest probability
Strategy 3: Multi-Timeframe FVG
Best For: Position trading, major moves
Timeframes: Combine Daily + 4H or 4H + 1H
Win Rate: 70-80%
Entry Rules:
1. Identify large FVG on higher timeframe (Daily/4H)
2. Wait for price to enter this HTF FVG
3. Switch to lower timeframe (4H/1H)
4. Look for LTF FVG within HTF FVG in same direction
5. Trade the LTF FVG fill
6. Stop: Below LTF FVG
7. Target: Exit HTF FVG or beyond
Why It Works: Timeframe alignment = institutional consensus
Strategy 4: FVG Rejection Trade
Best For: Quick scalps, day trading
Timeframes: 5min, 15min
Win Rate: 60-70%
Entry Rules:
1. Price enters FVG zone
2. Immediate rejection (strong reversal candle)
3. Enter on close of rejection candle
4. Tight stop beyond FVG
5. Quick target: 1-2R
Why It Works: Strong rejection = institutional defense of level
Strategy 5: FVG-to-FVG Trading
Best For: Momentum trading
Timeframes: 15min, 1H
Win Rate: 55-65%
Entry Rules:
1. Identify bullish FVG below and bearish FVG above
2. Enter long at bullish FVG, target bearish FVG
3. Or enter short at bearish FVG, target bullish FVG
4. Price often moves from one imbalance to another
5. Stop: Beyond trading FVG
6. Target: Opposite FVG
Why It Works: Price rebalances from one inefficiency to another
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ Settings Explained
Display Settings
Show Bullish/Bearish FVG
• Toggle each type on/off independently
• Customize colors for each FVG type
• Default: Green (bullish), Red (bearish)
• Tip: Use colors that contrast with your chart
Max FVG to Display (Default: 20)
• Limits how many gaps are shown at once
• Lower (10-15): Cleaner chart, recent gaps only
• Higher (30-50): More historical context
• Recommended: 15-25 for most trading
Show FVG Labels (Default: ON)
• Displays "FVG+" and "FVG-" text on gaps
• Shows 🎯 on active (nearest) gap
• Shows fill percentage (e.g., "FVG+ 35%")
• Turn OFF for minimal appearance
• Recommended: Keep ON for clarity
Extend Gaps (bars) (Default: 50)
• How far to extend gap boxes to the right
• Lower (20-30): Shorter boxes
• Higher (100+): Longer boxes, easier to see
• Gaps auto-extend until filled or limit reached
• Recommended: 40-60 bars
Filters
Min Gap Size % (Default: 0.05)
• Minimum gap size as percentage of price
• Filters out tiny, insignificant gaps
• Crypto: 0.05-0.15% (high volatility)
• Forex: 0.03-0.10% (moderate volatility)
• Stocks: 0.05-0.20% (varies by stock)
• Indices: 0.05-0.15%
• Adjust based on instrument's average move
Show Filled Gaps (Default: OFF)
• When ON: Shows gray boxes for filled gaps
• When OFF: Gaps disappear after mitigation
• Use ON: For learning and backtesting
• Use OFF: For clean, active trading view
Advanced Settings
Auto-Detect Mitigation (Default: ON)
• Automatically tracks when gaps are filled
• Updates fill percentage in real-time
• Marks gaps as "mitigated" when filled
• Recommended: Keep ON
Mitigation Type (Default: Full)
• Full: Gap considered filled when price closes through entire gap
• 50%: Gap considered filled at 50% (critical level)
• Partial: Gap considered filled on first touch
• For learning: Use "Full"
• For aggressive trading: Use "50%"
• For conservative trading: Use "Partial"
Highlight Nearest Gap (Default: ON)
• Highlights the closest unfilled gap to current price
• Active gap shown with 🎯 emoji and brighter color
• Helps focus on most relevant opportunity
• Recommended: Keep ON
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📱 Info Panel Guide
Bullish FVG Count
• Number of active (unfilled) bullish fair value gaps
• Higher number = More potential support zones below
• Multiple bullish FVGs = Strong rebalancing demand
Bearish FVG Count
• Number of active (unfilled) bearish fair value gaps
• Higher number = More potential resistance zones above
• Multiple bearish FVGs = Strong rebalancing supply
Bias Indicator
• ⬆ [color=green]Bullish:[/color] More bullish FVGs than bearish
• ⬇ [color=red]Bearish:[/color] More bearish FVGs than bullish
• ↔ Neutral: Equal FVGs on both sides
• Market tends to fill nearby gaps first
Target Indicator
• Shows nearest unfilled gap and distance
• Example: "Bull FVG -1.25%" = Bullish gap is 1.25% below price
• Example: "Bear FVG +0.85%" = Bearish gap is 0.85% above price
• Watch for price to reach these targets
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📱 Alert Setup
This indicator includes 4 alert types:
1. Price Entering Bullish FVG
• Fires when price drops into a bullish gap
• Action: Watch for bounce/reversal
• High-probability long setup developing
2. Price Entering Bearish FVG
• Fires when price rallies into a bearish gap
• Action: Watch for rejection/reversal
• High-probability short setup developing
3. New Bullish FVG Detected
• Fires when a new bullish gap forms
• Action: Mark zone for future fill
• New rebalancing target below identified
4. New Bearish FVG Detected
• Fires when a new bearish gap forms
• Action: Mark zone for future fill
• New rebalancing target above identified
To Set Up Alerts:
1. Click "Alert" button (clock icon)
2. Select "Fair Value Gap Detector"
3. Choose your alert condition
4. Configure notification method
5. Click "Create"
Pro Tip: Set "Price Entering" alerts to catch fills in real-time
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💎 Pro Tips & Best Practices
✅ DO:
• Wait for 50% fill - Middle of gap has highest win rate (65-70%)
• Use confirmation - Don't trade just because price touched gap
• Combine with structure - FVG + support/resistance = high probability
• Trade first fill - Unfilled gaps have better success rate than refilled
• Respect full fills - Once fully filled, gap is less reliable
• Use multiple timeframes - HTF FVGs are stronger than LTF
• Check session timing - FVGs work best during London/NY sessions
• Follow the bias - More bullish FVGs = favor longs
⚠️ DON'T:
• Don't blindly fade gaps - Wait for price action confirmation
• Don't ignore momentum - Strong trends can blow through FVGs
• Don't trade every gap - Quality over quantity
• Don't assume all gaps fill - About 70-80% fill, 20-30% don't
• Don't use tight stops - Allow room for wick into gap
• Don't overtrade - Wait for confluence and confirmation
• Don't fight trends - Best FVG trades are with higher TF trend
• Don't ignore fill percentage - 50% is often the sweet spot
🎯 Best Timeframes:
• Scalpers: 1min, 5min (many gaps, quick fills)
• Day Traders: 5min, 15min, 1H (balanced)
• Swing Traders: 1H, 4H, Daily (larger, more reliable gaps)
• Position Traders: 4H, Daily, Weekly (major imbalances)
🔥 Best Instruments:
• Excellent: BTC, ETH, ES, NQ, Forex majors (clean price action)
• Good: Gold, Oil, Major indices, Large-cap stocks
• Moderate: Altcoins, small-cap stocks (more noise)
• Best Markets: Trending markets with clear swings
⏰ Best Times for FVG Trading:
• London Session: High volume = reliable gap fills
• NY Session: Strong moves create quality gaps
• London-NY Overlap: Best time for gap creation and fills
• Asian Session: Lower probability, wait for London
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎓 Advanced FVG Concepts
FVG Mitigation Levels
Understanding fill percentages:
• 0-25% Fill: Gap barely touched, often continues without fill
• 25-50% Fill: Partial rebalancing, may reverse here
• 50% Fill: CRITICAL LEVEL - Highest probability reversal zone
• 50-75% Fill: Deep rebalancing, strong reversal likely
• 75-100% Fill: Full rebalancing, gap's purpose fulfilled
Why 50% Matters: Market seeks equilibrium, and 50% represents perfect balance
FVG Inversions
When price breaks through a gap completely:
• Bullish FVG that's broken becomes bearish (support → resistance)
• Bearish FVG that's broken becomes bullish (resistance → support)
• Inverted gaps are weaker than fresh gaps
• Trading: Can fade the inverted gap but with caution
FVG Confluence Zones
Multiple FVGs at similar level:
• Creates "super gap" or confluence zone
• Much higher probability of reaction
• Wider zone for entries (more room for stops)
• Often aligns with other institutional concepts
FVG + Order Block Combo
When FVG overlaps with Order Block:
• Double institutional concept
• Extremely high probability setup (75-85% win rate)
• Price drawn to fill gap AND test order block
• Use tight stops, generous targets (3-5R possible)
Nested FVGs (Multi-Timeframe)
Small FVG inside larger FVG:
• Daily FVG contains 4H FVG contains 1H FVG
• Trade the smallest FVG in direction of larger ones
• Highest probability when all aligned
• Progressive targets: Fill small → medium → large gaps
FVG Exhaustion
When price creates multiple FVGs in same direction:
• Indicates strong momentum/impulsive move
• Each gap represents acceleration
• Last gap often signals exhaustion
• Watch for reversal after filling final gap
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 Common FVG Patterns
Pattern 1: The Perfect Rebalance
• FVG forms during strong move
• Price continues 100+ pips
• Clean return to 50% of gap
• Immediate reversal
• Textbook setup, 70%+ win rate
Pattern 2: The Double Fill
• Price partially fills gap (25%)
• Weak reaction, continues
• Returns again for deeper fill (75%)
• Strong reversal on second fill
• Second fill often better entry
Pattern 3: The Blow-Through
• Price approaches gap
• Completely ignores it, no reaction
• Keeps going in same direction
• Sign of very strong momentum
Pattern 4: The Magnet Effect
• Price slowly grinds toward gap
• Accelerates as it gets close
• Quickly fills and reverses
• Common in ranging markets
Pattern 5: The False Fill
• Price wicks into gap briefly
• Immediately reverses without filling
• "Stop hunt" or liquidity grab
• Gap remains unfilled
• Often precedes strong move
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 What Makes This Different?
Unlike basic gap indicators, Fair Value Gap Detector:
• ICT Methodology - Based on proven institutional concepts
• Real-Time Fill Tracking - Shows percentage filled as it happens
• 3 Mitigation Types - Full, 50%, Partial for different strategies
• Active Gap Highlighting - Shows most relevant opportunity
• Smart Filtering - Minimum size to avoid noise
• Visual Clarity - Clean, professional appearance
• Auto-Management - Removes filled gaps automatically
• Distance Tracking - Know exactly where price needs to go
Based On Professional Concepts:
• ICT Fair Value Gap theory
• Market efficiency principles
• Price rebalancing dynamics
• Institutional order flow analysis
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 FVG Statistics & Probabilities
Based on ICT concepts and trader observations:
Gap Fill Rates:
• 70-80% of FVGs get filled eventually
• 60-70% show some reaction when filled
• 50% fill level has ~65% reversal rate
• Full fills have ~55% reversal rate
Timeframe Reliability:
• Daily FVGs: ~75-85% fill rate, strongest reactions
• 4H FVGs: ~70-80% fill rate, strong reactions
• 1H FVGs: ~65-75% fill rate, good reactions
• 15min FVGs: ~60-70% fill rate, moderate reactions
• 5min FVGs: ~55-65% fill rate, weaker reactions
Best Practices:
• First touch of gap = 65-70% win rate
• 50% fill = 65% win rate
• FVG + Order Block = 75-85% win rate
• Multi-timeframe aligned FVG = 70-80% win rate
• FVG in trending market = 60-70% win rate
Common Failures:
• Strong momentum blows through gaps (20-30% of time)
• Gaps in low-volume periods less reliable
• Very small gaps (<0.05%) often ignored
• Counter-trend gaps have lower success rate
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🙏 If You Find This Helpful
• ⭐ Leave your feedback
• 💬 Share your experience in the comments
• 🔔 Follow for updates and new tools
Questions about Fair Value Gaps? Feel free to ask in the comments.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Version History
• v1.0 - Initial release with 3-candle FVG detection and real-time fill tracking
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
Market Solver Pro: The automated system for disciplined traders. Includes: Trend Validation, Entries, and Risk Management. 📉 Stop Guessing. 📈 Start Executing.
Get the Signals & Free Guides:
➡️ patreon.com/marketsolverpro
Get the Signals & Free Guides:
➡️ patreon.com/marketsolverpro
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
Market Solver Pro: The automated system for disciplined traders. Includes: Trend Validation, Entries, and Risk Management. 📉 Stop Guessing. 📈 Start Executing.
Get the Signals & Free Guides:
➡️ patreon.com/marketsolverpro
Get the Signals & Free Guides:
➡️ patreon.com/marketsolverpro
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.