OPEN-SOURCE SCRIPT

Liquidity gap identifier mtf

625
This Pine Script v6 indicator called "Liquidity gap identifier mtf" detects and visually highlights price gaps (also known as imbalances, inefficiencies, or Fair Value Gaps in SMC/ICT trading) using multi-timeframe (MTF) support.How it works:It compares the current candle (or higher timeframe candle) with the candle two bars prior.
Bullish Gap (upward imbalance): When the low of the current candle is higher than the high of the candle from two bars ago (low > high[2]). This leaves an unfilled area below price.
Bearish Gap (downward imbalance): When the high of the current candle is lower than the low of the candle from two bars ago (high < low[2]). This leaves an unfilled area above price.

The script draws boxes (rectangles) to mark these gaps:Boxes start between the relevant candles and automatically expand to the right (to the current bar) as new bars form.
Supports MTF: You can display gaps from a higher timeframe (e.g., daily gaps on a 15-minute chart) while keeping the main chart clean.
Customization: Colors, transparency, and the option to hide filled gaps (when price trades through the gap, the box is removed).
Uses arrays for efficient management of multiple active boxes with a FIFO (first-in, first-out) limit to avoid exceeding TradingView's max_boxes_count.

Key FeaturesExpanding boxes — The gaps stay visible and stretch rightward until filled or the max limit is reached.
Auto cleanup — Removes oldest gaps when the user-defined max is hit.
Hide filled gaps option (very useful for clean charts).
Clean MTF implementation using request.security() with proper gap handling.

Main Use CasesFair Value Gap / Imbalance Trading (ICT/SMC)Many traders use these gaps as magnet zones or areas that price is likely to return to and "fill" (mitigate).
Bullish gaps often act as support; bearish gaps as resistance.

Multi-Timeframe ConfluencePlot higher-timeframe gaps on your lower-timeframe chart to see where larger players might have left inefficiencies.
Example: Show 4H or Daily liquidity gaps while scalping on 5m/15m.

Gap Fill StrategiesEnter trades expecting price to retrace and fill the gap (mean reversion).
Or use unfilled gaps as bias: Trade in the direction of the gap (continuation) until it fills.

Liquidity Void IdentificationThese gaps represent areas with low liquidity / rapid price movement. Institutions often target or avoid them, making them useful for stop hunts, order blocks, or breaker setups.

Clean Chart ManagementThe "Hide Filled Gaps" feature + max boxes limit keeps the chart from becoming cluttered with old, irrelevant zones.

Typical Trading ContextTraders combine this with:Order blocks / breaker blocks
Market structure (BOS/CHOCH)
Volume profile or session liquidity
Higher-timeframe bias

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

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.