Indicator · Pine Script v5 · On the chart

CTLV v2 Liquidity Void Map

by AssetWhisper

An overlay indicator that maps price voids as boxes on the chart: three-candle fair value gaps and opening gaps, mostly from a higher timeframe such as four hours, with an option to include chart-timeframe voids.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code214
Settings11inputs
LicenceMPL-2.0
Last update7 weeks ago10 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

214 lines of Pine Script v5 from indicators/CTLV_Liquidity_Void_Map.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

CTLV_Liquidity_Void_Map.pine
//@version=5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AssetWhisper — https://assetwhisper.com/indicators/
// ============================================================================
//  CTLV v2 — Cross-TF Liquidity Void Map
//  Idea: los huecos de precio (FVG de 3 velas y gaps de apertura) en marcos
//  superiores actúan como imanes: el precio tiende a volver a "rellenarlos".
//  v2 detecta los voids del HTF sin repintar (usa velas HTF cerradas), mide el
//  relleno por penetración de mecha desde el lado de entrada, gestiona las cajas
//  (se extienden, cambian de opacidad con el relleno y se retiran al mitigarse) y
//  publica los imanes más cercanos por encima y por debajo con su distancia.
// ============================================================================
indicator("CTLV v2 — Liquidity Void Map", shorttitle="CTLV v2", overlay=true, max_boxes_count=200, max_labels_count=200, max_lines_count=20)

grpD = "Detección"
htfTF      = input.timeframe("240", "Higher timeframe", group=grpD)
useLTF     = input.bool(false, "Also map chart-timeframe voids", group=grpD)
minSizePct = input.float(0.10, "Min void size (% of price)", minval=0.0, maxval=5.0, step=0.05, group=grpD)
minSizeATR = input.float(0.20, "Min void size (ATR mult)", minval=0.0, maxval=3.0, step=0.05, group=grpD)
detectGaps = input.bool(true, "Include open gaps (not only FVG)", group=grpD)
grpM = "Mitigación"
mitTh    = input.float(50, "Mitigated at fill % >=", minval=10, maxval=100, step=5, group=grpM)
hideMit  = input.bool(true, "Hide mitigated voids", group=grpM)
maxVoids = input.int(40, "Max stored voids", minval=5, maxval=150, group=grpM)
maxAge   = input.int(1500, "Max age (bars)", minval=100, maxval=5000, group=grpM)
grpV = "Visual"
showMagnets = input.bool(true, "Show nearest magnets", group=grpV)
showLabels  = input.bool(true, "Labels on HTF voids", group=grpV)

atr = ta.atr(14)
htfValid = timeframe.in_seconds(htfTF) > timeframe.in_seconds(timeframe.period)

// === ALMACÉN (arrays paralelos) ===
var array<float>  vTop  = array.new<float>()
var array<float>  vBot  = array.new<float>()
var array<int>    vSide = array.new<int>()       // +1 void bajo el precio (bull), -1 sobre el precio (bear)
var array<int>    vBar  = array.new<int>()
var array<string> vTag  = array.new<string>()    // "HTF FVG" | "HTF GAP" | "LTF FVG" | "LTF GAP"
var array<float>  vFill = array.new<float>()
var array<bool>   vMit  = array.new<bool>()
var array<box>    vBox  = array.new<box>()
var array<label>  vLbl  = array.new<label>()

colorFor(tag, sideV) =>
    isHTF = str.startswith(tag, "HTF")
    sideV > 0 ? (isHTF ? color.teal : color.green) : (isHTF ? color.purple : color.red)

removeVoid(i) =>
    box.delete(array.get(vBox, i))
    lb = array.get(vLbl, i)
    if not na(lb)
        label.delete(lb)
    array.remove(vTop, i)
    array.remove(vBot, i)
    array.remove(vSide, i)
    array.remove(vBar, i)
    array.remove(vTag, i)
    array.remove(vFill, i)
    array.remove(vMit, i)
    array.remove(vBox, i)
    array.remove(vLbl, i)

addVoid(top, bot, sideV, tag, leftBar) =>
    vSize = top - bot
    ok = vSize > 0 and vSize >= close * minSizePct / 100 and vSize >= atr * minSizeATR
    if ok
        if array.size(vTop) >= maxVoids
            removeVoid(0)
        col = colorFor(tag, sideV)
        bx = box.new(leftBar, top, bar_index, bot, border_color=color.new(col, 40), border_width=1, bgcolor=color.new(col, 85))
        label lb = na
        if showLabels and str.startswith(tag, "HTF")
            lb := label.new(leftBar, top, tag, style=label.style_label_down, color=color.new(col, 30), textcolor=color.white, size=size.tiny)
        array.push(vTop, top)
        array.push(vBot, bot)
        array.push(vSide, sideV)
        array.push(vBar, bar_index)
        array.push(vTag, tag)
        array.push(vFill, 0.0)
        array.push(vMit, false)
        array.push(vBox, bx)
        array.push(vLbl, lb)

// === DETECCIÓN HTF (no repintante: velas HTF cerradas [1] y [3], lookahead_on) ===
[hH1, hL1, hH3, hL3, hO1, hC2, hT1] = request.security(syminfo.tickerid, htfTF, [high[1], low[1], high[3], low[3], open[1], close[2], time[1]], lookahead=barmerge.lookahead_on)
newHTF = htfValid and ta.change(hT1) != 0
htfBullFVG = newHTF and hL1 > hH3
htfBearFVG = newHTF and hH1 < hL3
if htfBullFVG
    addVoid(hL1, hH3, 1, "HTF FVG", bar_index)
if htfBearFVG
    addVoid(hL3, hH1, -1, "HTF FVG", bar_index)
if newHTF and detectGaps
    if hO1 > hC2
        addVoid(hO1, hC2, 1, "HTF GAP", bar_index)
    if hO1 < hC2
        addVoid(hC2, hO1, -1, "HTF GAP", bar_index)

// === DETECCIÓN EN EL TIMEFRAME DEL GRÁFICO (opcional) ===
if useLTF
    if low > high[2]
        addVoid(low, high[2], 1, "LTF FVG", bar_index - 1)
    if high < low[2]
        addVoid(low[2], high, -1, "LTF FVG", bar_index - 1)
    if detectGaps
        if open > close[1]
            addVoid(open, close[1], 1, "LTF GAP", bar_index)
        if open < close[1]
            addVoid(close[1], open, -1, "LTF GAP", bar_index)

// === ACTUALIZACIÓN: relleno, extensión, mitigación, caducidad ===
nV = array.size(vTop)
if nV > 0
    for i = nV - 1 to 0
        top = array.get(vTop, i)
        bot = array.get(vBot, i)
        sd  = array.get(vSide, i)
        age = bar_index - array.get(vBar, i)
        if age > maxAge
            removeVoid(i)
        else if not array.get(vMit, i)
            vs = top - bot
            fillNow = sd > 0 ? (top - low) / vs * 100 : (high - bot) / vs * 100
            fillNow := math.max(0.0, math.min(100.0, fillNow))
            fillMax = math.max(array.get(vFill, i), fillNow)
            array.set(vFill, i, fillMax)
            bx = array.get(vBox, i)
            box.set_right(bx, bar_index)
            col = colorFor(array.get(vTag, i), sd)
            box.set_bgcolor(bx, color.new(col, math.round(85 + fillMax * 0.1)))
            if fillMax >= mitTh
                array.set(vMit, i, true)
                if hideMit
                    removeVoid(i)
                else
                    box.set_bgcolor(bx, color.new(color.gray, 92))
                    box.set_border_color(bx, color.new(color.gray, 60))
                    lb = array.get(vLbl, i)
                    if not na(lb)
                        label.set_text(lb, array.get(vTag, i) + " ✓")

// === IMANES: void no mitigado más cercano por encima y por debajo ===
float  magAbove = na
float  magBelow = na
string tagAbove = ""
string tagBelow = ""
nV2 = array.size(vTop)
activeCount = 0
if nV2 > 0
    for i = 0 to nV2 - 1
        if not array.get(vMit, i)
            activeCount += 1
            top = array.get(vTop, i)
            bot = array.get(vBot, i)
            if bot > close and (na(magAbove) or bot < magAbove)
                magAbove := bot
                tagAbove := array.get(vTag, i)
            if top < close and (na(magBelow) or top > magBelow)
                magBelow := top
                tagBelow := array.get(vTag, i)

distAbovePct = na(magAbove) ? na : (magAbove - close) / close * 100
distBelowPct = na(magBelow) ? na : (close - magBelow) / close * 100
distAboveATR = na(magAbove) or atr <= 0 ? na : (magAbove - close) / atr
distBelowATR = na(magBelow) or atr <= 0 ? na : (close - magBelow) / atr

var line  magUpLine = na
var line  magDnLine = na
var label magUpLbl  = na
var label magDnLbl  = na
if showMagnets and barstate.islast
    if na(magUpLine)
        magUpLine := line.new(bar_index - 20, close, bar_index + 5, close, color=color.new(color.yellow, 30), style=line.style_dashed, width=2)
        magDnLine := line.new(bar_index - 20, close, bar_index + 5, close, color=color.new(color.yellow, 30), style=line.style_dashed, width=2)
        magUpLbl  := label.new(bar_index + 5, close, "", style=label.style_label_left, color=color.new(color.yellow, 20), textcolor=color.black, size=size.small)
        magDnLbl  := label.new(bar_index + 5, close, "", style=label.style_label_left, color=color.new(color.yellow, 20), textcolor=color.black, size=size.small)
    yUp = na(magAbove) ? close : magAbove
    yDn = na(magBelow) ? close : magBelow
    line.set_xy1(magUpLine, bar_index - 20, yUp)
    line.set_xy2(magUpLine, bar_index + 5, yUp)
    line.set_xy1(magDnLine, bar_index - 20, yDn)
    line.set_xy2(magDnLine, bar_index + 5, yDn)
    label.set_xy(magUpLbl, bar_index + 5, yUp)
    label.set_text(magUpLbl, na(magAbove) ? "no void above" : "▲ " + tagAbove + "  +" + str.tostring(distAbovePct, "#.##") + "% (" + str.tostring(distAboveATR, "#.#") + " ATR)")
    label.set_xy(magDnLbl, bar_index + 5, yDn)
    label.set_text(magDnLbl, na(magBelow) ? "no void below" : "▼ " + tagBelow + "  -" + str.tostring(distBelowPct, "#.##") + "% (" + str.tostring(distBelowATR, "#.#") + " ATR)")

// === SEÑALES (usando los imanes de la barra anterior) ===
touchAbove  = not na(magAbove[1]) and high >= magAbove[1]
touchBelow  = not na(magBelow[1]) and low <= magBelow[1]
rejectAbove = touchAbove and close < magAbove[1]
rejectBelow = touchBelow and close > magBelow[1]
plotshape(rejectAbove, "Rejection from void above", style=shape.triangledown, location=location.abovebar, color=color.purple, size=size.tiny, text="REJ")
plotshape(rejectBelow, "Rejection from void below", style=shape.triangleup, location=location.belowbar, color=color.teal, size=size.tiny, text="REJ")
plot(magAbove, "Nearest void above (export)", display=display.none)
plot(magBelow, "Nearest void below (export)", display=display.none)

var table t = table.new(position.top_left, 2, 5, bgcolor=color.new(color.black, 60))
table.cell(t, 0, 0, "HTF", text_color=color.white, text_size=size.small)
table.cell(t, 1, 0, htfValid ? htfTF : "INVALID (<= chart)", text_color=htfValid ? color.lime : color.red, text_size=size.small)
table.cell(t, 0, 1, "Active voids", text_color=color.white, text_size=size.small)
table.cell(t, 1, 1, str.tostring(activeCount), text_color=color.white, text_size=size.small)
table.cell(t, 0, 2, "Magnet above", text_color=color.white, text_size=size.small)
table.cell(t, 1, 2, na(magAbove) ? "-" : str.tostring(magAbove, format.mintick) + "  (+" + str.tostring(distAbovePct, "#.##") + "%)", text_color=color.yellow, text_size=size.small)
table.cell(t, 0, 3, "Magnet below", text_color=color.white, text_size=size.small)
table.cell(t, 1, 3, na(magBelow) ? "-" : str.tostring(magBelow, format.mintick) + "  (-" + str.tostring(distBelowPct, "#.##") + "%)", text_color=color.yellow, text_size=size.small)
table.cell(t, 0, 4, "Nearest", text_color=color.white, text_size=size.small)
table.cell(t, 1, 4, na(distAbovePct) and na(distBelowPct) ? "-" : na(distBelowPct) or (not na(distAbovePct) and distAbovePct < distBelowPct) ? "ABOVE " + tagAbove : "BELOW " + tagBelow, text_color=color.white, text_size=size.small)

// === ALERTAS ===
alertcondition(htfBullFVG or htfBearFVG, "CTLV New HTF FVG", "CTLV v2: new higher-timeframe fair value gap")
alertcondition(touchAbove, "CTLV Touch void above", "CTLV v2: price reached the nearest void above")
alertcondition(touchBelow, "CTLV Touch void below", "CTLV v2: price reached the nearest void below")
alertcondition(rejectAbove or rejectBelow, "CTLV Void rejection", "CTLV v2: price rejected from a liquidity void")

Overview

CTLV v2 Liquidity Void Map uses closed higher-timeframe candles, tracks how much of each void has been filled and hides those past a fill threshold. Minimum size, maximum count and age are inputs, and the nearest unfilled voids above and below are highlighted.

Details

Published by

AssetWhisper on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Higher timeframetimeframe240htfTF
Also map chart-timeframe voidsboolfalseuseLTF
Min void size (% of price)float0.10minSizePct
Min void size (ATR mult)float0.20minSizeATR
Include open gaps (not only FVG)booltruedetectGaps
Mitigated at fill % >=float50mitTh
Hide mitigated voidsbooltruehideMit
Max stored voidsint40maxVoids
Max age (bars)int1500maxAge
Show nearest magnetsbooltrueshowMagnets
Labels on HTF voidsbooltrueshowLabels
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows

DE-tracker

by Allen1212
303 stars

This indicator plots labels on the TradingView price chart to mark ARK Invest's buy and sell trades for the DE stock. Buy transactions appear in green with X1 or X2 multipliers showing the number of ARK ETFs involved on the same day; sells appear in red. The m

Indicator v4 Support & resistanceSMC / ICT / price action
Updated 2 years ago · None stated GitHub repository of DE-tracker

This Pine Script indicator plots a ZigZag on the price chart. It identifies reversal points when price moves more than a set percentage from the last pivot. The script calculates forecasts using zigzag data and labels detected geometric patterns including harm

Indicator v4 TrendSupport & resistance

Golden Bullet Strategy

by TradersPost
228 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

Open Source Fractal

by cantolab
183 stars

This indicator implements the Fractal Model concept to plot market structure shifts, liquidity sweeps, and Change in State of Delivery (CISD) levels. It overlays custom higher-timeframe candle previews, open prices, and time markers directly on the price chart

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MIT GitHub repository of Open Source Fractal

Swing Failure Signals

by Ganador1
154 stars

This indicator calculates pivot highs and pivot lows to detect liquidity sweeps and Swing Failure Patterns. It identifies when price breaks past recent key swing highs or lows within a configurable historical window, then looks for a quick reversal or change i

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · Apache-2.0 GitHub repository of Swing Failure Signals

More SMC / ICT scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers