PROTECTED SOURCE SCRIPT

FVG and OB

66
🧠 Concept Behind the “FVG and OB” Indicator

This indicator merges two core ICT (Inner Circle Trader) concepts — Fair Value Gaps (FVGs) and Order Blocks (OBs) — into one clean, dynamic visualization tool.
It is designed for professional price-action traders who want to track institutional imbalances and smart money footprints directly on the chart.

🟩 FAIR VALUE GAP (FVG)

An FVG represents an imbalance in price caused by aggressive buying or selling where the market fails to offer two-way liquidity.
It’s typically created when a strong candle leaves a visible “gap” between the previous candle’s high and the next candle’s low (for bullish FVG), or vice versa (for bearish FVG).

In this indicator:

🟢 Bullish FVGs are drawn when low > high[2]

🔴 Bearish FVGs are drawn when high < low[2]

Each gap box dynamically extends to the right until it is mitigated (partially or fully filled).

You can choose between two mitigation modes:

Boundary Touch (default): The FVG is considered mitigated once price touches the gap boundary.

Full Fill: The FVG remains active until the entire gap range is filled.

This gives you real-time awareness of whether liquidity has been rebalanced — a key ICT concept in identifying market turning points.

🟥 ORDER BLOCK (OB)

An Order Block represents the last opposing candle before a strong impulsive move.
It is where institutional traders likely executed large block orders, creating supply or demand zones that price often revisits.

In this script, an OB is automatically drawn:

🟥 Bearish OBs form after a strong down move (usually following a bearish FVG).

🟩 Bullish OBs form after a strong up move (usually following a bullish FVG).

Key features:

The indicator can detect OBs in two ways:

Only FVG’s First Candle: A stricter mode aligning OB formation directly with FVG events.

Classic (Last Opposite Color): A more traditional ICT-style detection that finds the last candle of the opposite color within a defined lookback range.

OBs auto-expand with the next candle’s wick, so any extra high/low beyond the original OB is included by default.

Each OB remains extended until mitigated — when price revisits and closes the imbalance.

⚙️ CONTROL & CUSTOMIZATION

You can control the entire behavior and visualization through the settings panel:

Display Mode: Show only FVGs, only OBs, or both simultaneously.

Mitigation Mode: Choose how strict the FVG closure logic should be.

Body-Only Option: Restrict OB calculation to candle bodies instead of wicks for cleaner structure.

Individual Color Settings: Customize border and fill colors for each block type.

Lookback Depth: Define how far back the system searches for valid OB structures.

The result is a clean, layered representation of institutional footprints — with automatic cleanup logic that prevents chart clutter and keeps only active zones visible.

📊 PRACTICAL APPLICATION

Use this indicator to:

Identify imbalances left by aggressive moves (potential retracement targets).

Confirm confluences between FVGs and OBs — the overlap areas often mark powerful reaction zones.

Track mitigation progress as price revisits those zones.

Refine entry timing when price reacts to unmitigated OBs or fills the last untested FVG.

🧩 TECHNICAL DESIGN

Built in Pine Script v5 with fully modular code architecture.

FVG and OB modules can be toggled or used independently.

Uses arrays for efficient management of multiple boxes.

Auto-updates in real-time and mitigates per-bar to minimize lag.

Designed for multi-timeframe backtesting compatibility.

💡 Summary

This tool visually bridges two of the most powerful Smart Money Concepts —
FVG = imbalance zones and OB = institutional origin blocks.
Together, they help traders map out liquidity flows, identify premium/discount zones, and anticipate where price is likely to react next.

🧑‍💻 Credits

Based on ICT & Smart Money Concepts, rewritten in modular PineScript with precision mitigation logic.
# For educational and analytical purposes only.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.