Indicator · Pine Script v6 · On the chart

Liquidity Matrix EVO

by h33rnan

A Pine v6 indicator that finds swing-based liquidity zones on the price chart and classifies them by age, volume and rejection strength as weak, maturing or wall zones.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code388
Settings16inputs
LicenceMIT
Last update6 months ago11 Apr 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

388 lines of Pine Script v6 from Liquidity-Matrix-EVO.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

Liquidity-Matrix-EVO.pine
//@version=6
indicator('Liquidity Matrix EVO', max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500, max_polylines_count = 100, max_bars_back = 5000, calc_bars_count = 10000, overlay = true)

// ═══════════════════════════════════════════════════════════════════════════════
// 1. TEMAS & UI ADAPTATIVA (STANDARD "SURGICAL")
// ═══════════════════════════════════════════════════════════════════════════════
string G_THEME = "Estética Quirúrgica & UI"
string themeChoice = input.string("Artic", "Tema Visual", options = ["Artic", "Mono"], group=G_THEME)
bool isLight = input.bool(false, "☀️ Modo Claro", group=G_THEME)
string hudSizeInput = input.string("Small", "Tamaño del Panel", options=["Tiny", "Small", "Normal", "Large"], group=G_THEME)

string hudSize = hudSizeInput == "Tiny" ? size.tiny : hudSizeInput == "Small" ? size.small : hudSizeInput == "Normal" ? size.normal : size.large

color thBull = themeChoice == "Mono" ? (isLight ? #616161 : #9e9e9e) : (isLight ? #0288d1 : #4fc3f7) 
color thBear = themeChoice == "Mono" ? (isLight ? #212121 : #424242) : (isLight ? #512da8 : #b39ddb) 
color thSweep = themeChoice == "Mono" ? (isLight ? #000000 : #ffffff) : (isLight ? #0097a7 : #00e5ff) 

color bgHud = isLight ? color.new(color.white, 20) : color.new(color.black, 90)
color borderHud = isLight ? color.new(color.gray, 60) : color.new(color.gray, 85)
color txtMain = isLight ? color.black : color.white
color txtSub = isLight ? color.new(color.black, 30) : color.gray

color sweepBg = themeChoice == "Mono" ? color.blue : color.new(thSweep, 20)
color sweepTxt = themeChoice == "Mono" ? color.white : color.black

// ══════════════════════════════════════════════════════════════════════════
// INPUTS DEL MOTOR DE LIQUIDEZ (DESBLOQUEADO PARA DEEP MEMORY)
// ══════════════════════════════════════════════════════════════════════════
string G_LIQ = "Motor de Liquidez"
int swingLength = input.int(10, "Longitud Swing", minval=3, maxval=50, group=G_LIQ)
int liqStrength = input.int(2, "Fuerza Mínima", minval=1, maxval=10, group=G_LIQ)
int extendBars = input.int(50, "Extensión Líneas", minval=10, maxval=200, group=G_LIQ)
int lookbackBars = input.int(300, "Velas de Análisis Histórico", minval=20, maxval=5000, group=G_LIQ) // FIX: Aumentado de 500 a 5000
int maxZoneAge = input.int(3000, "Vida Máxima de Zona (Velas)", minval=100, maxval=10000, group=G_LIQ) // NEW: Control Quant de edad
int maxZonesRender = input.int(150, "Límite de Zonas Activas", minval=10, maxval=400, group=G_LIQ) // NEW: Ampliación de buffer visual
float tolerancePct = input.float(0.3, "Tolerancia %", minval=0.1, maxval=2.0, step=0.1, group=G_LIQ)
float clusterDistance = input.float(0.5, "Agrupación de Zonas %", minval=0.1, maxval=3.0, step=0.1, group=G_LIQ)

string G_ADV = "Análisis Institucional (Quant)"
float volumeWeight = input.float(1.5, "Peso del Volumen", minval=0.5, maxval=3.0, step=0.1, group=G_ADV)
float rejectionWeight = input.float(2.0, "Peso de Rechazos", minval=1.0, maxval=5.0, step=0.5, group=G_ADV)
float wickStrength = input.float(0.3, "Sensibilidad de Mechas", minval=0.1, maxval=0.8, step=0.1, group=G_ADV)
bool useVolumeAnalysis = input.bool(true, "Analizar Volumen", group=G_ADV)
bool detectLiquidityGrabs = input.bool(true, "Detectar Trampas (Sweeps)", group=G_ADV)

// ══════════════════════════════════════════════════════════════════════════
// TIPOS DE DATOS & VARIABLES GLOBALES
// ══════════════════════════════════════════════════════════════════════════
type LiquidityZone
    line zoneLine
    label zoneLabel
    float price
    float rawStrength
    float adjustedStrength
    int touches
    int rejections
    float volMultiplier
    int birthBar
    bool isHigh
    bool hadLiqGrab
    string baseText

type SweepGrab
    label lbl
    float extremePrice
    bool isHigh

var array<LiquidityZone> activeZones = array.new<LiquidityZone>()
var array<SweepGrab> activeSweeps = array.new<SweepGrab>()

// ══════════════════════════════════════════════════════════════════════════
// FUNCIONES DE DETECCIÓN AVANZADA
// ══════════════════════════════════════════════════════════════════════════
hasRejection(int index, bool isHigh) =>
    bodySize = math.abs(close[index] - open[index])
    totalSize = high[index] - low[index]
    if totalSize == 0
        false
    else if isHigh
        upperWick = high[index] - math.max(close[index], open[index])
        upperWick > bodySize * wickStrength and upperWick > totalSize * 0.4
    else
        lowerWick = math.min(close[index], open[index]) - low[index]
        lowerWick > bodySize * wickStrength and lowerWick > totalSize * 0.4

getAdvancedLiquidityScore(float priceLevel, bool isHighZone) =>
    tolerance = priceLevel * (tolerancePct / 100)
    touches = 0
    rejections = 0
    totalVolume = 0.0
    
    for i = 1 to math.min(lookbackBars, bar_index)
        if bar_index - i >= 0
            highTouch = math.abs(high[i] - priceLevel) <= tolerance
            lowTouch = math.abs(low[i] - priceLevel) <= tolerance
            
            if isHighZone and highTouch
                touches += 1
                totalVolume += volume[i]
                if hasRejection(i, true)
                    rejections += 1
            
            if not isHighZone and lowTouch
                touches += 1
                totalVolume += volume[i]
                if hasRejection(i, false)
                    rejections += 1
    
    rawScore = touches
    adjustedScore = float(touches)
    volMult = 1.0
    
    if rejections > 0
        adjustedScore := adjustedScore * (1 + rejections * (rejectionWeight - 1) / touches)
    
    if useVolumeAnalysis and touches > 0
        avgVol = totalVolume / touches
        marketAvgVol = ta.sma(volume, 50)
        if avgVol > marketAvgVol
            volMult := avgVol / marketAvgVol
            volMultiplierWeight = math.min(volumeWeight, volMult)
            adjustedScore := adjustedScore * volMultiplierWeight
    
    [rawScore, adjustedScore, touches, rejections, volMult]

detectLiquidityGrab(float zonePrice, bool isHigh) =>
    if not detectLiquidityGrabs
        false
    else
        tolerance = zonePrice * (tolerancePct / 100)
        result = false
        for i = 1 to math.min(10, bar_index)
            if isHigh
                penetration = high[i] > zonePrice and close[i] < (zonePrice - tolerance)
                highVolume = useVolumeAnalysis ? volume[i] > ta.sma(volume, 20) * 1.2 : true
                if penetration and highVolume
                    result := true
                    break
            else
                penetration = low[i] < zonePrice and close[i] > (zonePrice + tolerance)
                highVolume = useVolumeAnalysis ? volume[i] > ta.sma(volume, 20) * 1.2 : true
                if penetration and highVolume
                    result := true
                    break
        result

isZoneBroken(LiquidityZone zone) =>
    tolerance = zone.price * (tolerancePct / 100)
    if zone.isHigh
        close > zone.price + tolerance and close[1] > zone.price
    else
        close < zone.price - tolerance and close[1] < zone.price

findNearbyZoneIndex(float price, bool isHigh) =>
    foundIdx = -1
    clusterTolerance = price * (clusterDistance / 100)
    if array.size(activeZones) > 0
        for i = 0 to array.size(activeZones) - 1
            zone = array.get(activeZones, i)
            if zone.isHigh == isHigh and math.abs(zone.price - price) <= clusterTolerance
                foundIdx := i
                break
    foundIdx

createZone(float priceLevel, float rawStr, float adjStr, int touches, int rejections, float volMult, bool isHigh) =>
    lineColor = isHigh ? color.new(thBear, 20) : color.new(thBull, 20)
    lineWidth = adjStr >= 8 ? 3 : (adjStr >= 5 ? 2 : 1)
    lineStyle = rejections >= 2 ? line.style_solid : line.style_dashed
    
    newLine = line.new(bar_index - swingLength, priceLevel, bar_index + extendBars, priceLevel, color=lineColor, width=lineWidth, style=lineStyle)
    
    strengthEmoji = adjStr >= 8 ? "🔥" : (adjStr >= 5 ? "⭐" : "")
    rejectEmoji = rejections >= 2 ? "⚡" : ""
    
    baseTxt = (isHigh ? "R: " : "S: ") + str.tostring(priceLevel, format.mintick) + " | STR: " + str.tostring(math.round(adjStr), "#") + " " + strengthEmoji + rejectEmoji + " | VOL: " + str.tostring(volMult, "#.#") + "x"
    
    newLabel = label.new(bar_index - swingLength, priceLevel, text=baseTxt, style=isHigh ? label.style_label_down : label.style_label_up, color=color.new(bgHud, 30), textcolor=isLight ? color.black : color.white, size=size.tiny, textalign=text.align_left)
    
    LiquidityZone.new(newLine, newLabel, priceLevel, rawStr, adjStr, touches, rejections, volMult, bar_index, isHigh, false, baseTxt)

updateZoneExtension(LiquidityZone zone) =>
    if not na(zone.zoneLine)
        line.set_x2(zone.zoneLine, bar_index + extendBars)
    if not na(zone.zoneLabel)
        age = bar_index - zone.birthBar
        string classIcon = ""
        if age > 80 and zone.adjustedStrength >= 5
            classIcon := " 🛡️"
        else if age <= 30 or zone.adjustedStrength <= 2
            classIcon := " ⚠️"
        else
            classIcon := " ⏳"
            
        label.set_text(zone.zoneLabel, zone.baseText + " | AGE: " + str.tostring(age) + "b" + classIcon)

deleteZone(LiquidityZone zone) =>
    if not na(zone.zoneLine)
        line.delete(zone.zoneLine)
    if not na(zone.zoneLabel)
        label.delete(zone.zoneLabel)

getDistanceToZone(float zonePrice) =>
    distPct = (zonePrice - close) / close * 100
    [math.abs(distPct), distPct]

analyzePriceBias() =>
    rsi = ta.rsi(close, 14)
    macdLine = ta.ema(close, 12) - ta.ema(close, 26)
    macdSignal = ta.ema(macdLine, 9)
    sma20 = ta.sma(close, 20)
    
    bullish = 0
    bearish = 0
    
    if close > sma20
        bullish += 1
    else
        bearish += 1
        
    if rsi > 55
        bullish += 1
    else if rsi < 45
        bearish += 1
        
    if macdLine > macdSignal
        bullish += 1
    else
        bearish += 1
        
    bias = bullish > bearish ? 1 : (bearish > bullish ? -1 : 0)
    strength = math.abs(bullish - bearish)
    [bias, strength, bullish, bearish]

getClosestZone(bool isHigh) =>
    var LiquidityZone closest = na
    closest := na
    var float minDist = 999999.9
    minDist := 999999.9
    
    if array.size(activeZones) > 0
        for zone in activeZones
            if zone.isHigh == isHigh
                [absDist, _] = getDistanceToZone(zone.price)
                if absDist < minDist
                    minDist := absDist
                    closest := zone
    closest

// ══════════════════════════════════════════════════════════════════════════
// LÓGICA PRINCIPAL DEL MOTOR
// ══════════════════════════════════════════════════════════════════════════
pivotHigh = ta.pivothigh(high, swingLength, swingLength)
pivotLow = ta.pivotlow(low, swingLength, swingLength)

if not na(pivotHigh)
    priceLevel = high[swingLength]
    [rawScore, adjScore, touches, rejections, volMult] = getAdvancedLiquidityScore(priceLevel, true)
    
    if adjScore >= liqStrength
        idx = findNearbyZoneIndex(priceLevel, true)
        if idx == -1
            newZone = createZone(priceLevel, rawScore, adjScore, touches, rejections, volMult, true)
            array.push(activeZones, newZone)
        else
            existingZone = array.get(activeZones, idx)
            if adjScore > existingZone.adjustedStrength
                deleteZone(existingZone)
                updatedZone = createZone(priceLevel, rawScore, adjScore, touches, rejections, volMult, true)
                array.set(activeZones, idx, updatedZone)

if not na(pivotLow)
    priceLevel = low[swingLength]
    [rawScore, adjScore, touches, rejections, volMult] = getAdvancedLiquidityScore(priceLevel, false)
    
    if adjScore >= liqStrength
        idx = findNearbyZoneIndex(priceLevel, false)
        if idx == -1
            newZone = createZone(priceLevel, rawScore, adjScore, touches, rejections, volMult, false)
            array.push(activeZones, newZone)
        else
            existingZone = array.get(activeZones, idx)
            if adjScore > existingZone.adjustedStrength
                deleteZone(existingZone)
                updatedZone = createZone(priceLevel, rawScore, adjScore, touches, rejections, volMult, false)
                array.set(activeZones, idx, updatedZone)

// Barridos (Sweeps) - Creación
if array.size(activeZones) > 0
    for zone in activeZones
        if not zone.hadLiqGrab and detectLiquidityGrab(zone.price, zone.isHigh)
            zone.hadLiqGrab := true
            sweepExt = zone.isHigh ? high[1] : low[1]
            lbl = label.new(bar_index[1], sweepExt, text="💧 SWEEP", style=zone.isHigh ? label.style_label_down : label.style_label_up, color=sweepBg, textcolor=sweepTxt, size=size.tiny)
            array.push(activeSweeps, SweepGrab.new(lbl, sweepExt, zone.isHigh))

// MITIGACIÓN DE SWEEPS
if array.size(activeSweeps) > 0
    for i = array.size(activeSweeps) - 1 to 0
        swp = array.get(activeSweeps, i)
        isBurned = swp.isHigh ? (high > swp.extremePrice) : (low < swp.extremePrice)
        if isBurned
            label.delete(swp.lbl)
            array.remove(activeSweeps, i)

// Limpieza de Arreglos Principales y Clasificación Cinética (DEEP MEMORY FIX)
int wallZones = 0
int weakZones = 0
int evoZones = 0

if array.size(activeZones) > 0
    for i = array.size(activeZones) - 1 to 0
        zone = array.get(activeZones, i)
        age = bar_index - zone.birthBar
        
        if age > 80 and zone.adjustedStrength >= 5
            wallZones += 1
        else if age <= 30 or zone.adjustedStrength <= 2
            weakZones += 1
        else
            evoZones += 1
            
        // El nuevo límite de edad dictado por el usuario
        if isZoneBroken(zone) or (age > maxZoneAge)
            deleteZone(zone)
            array.remove(activeZones, i)
        else
            updateZoneExtension(zone)

// El nuevo límite de matriz dictado por el usuario
if array.size(activeZones) > maxZonesRender
    oldestZone = array.shift(activeZones)
    deleteZone(oldestZone)

// ══════════════════════════════════════════════════════════════════════════
// PANEL DE ANÁLISIS (SURGICAL HUD)
// ══════════════════════════════════════════════════════════════════════════
[bias, biasStrength, bullishSignals, bearishSignals] = analyzePriceBias()
closestRes = getClosestZone(true)
closestSup = getClosestZone(false)

string biasStr = bias > 0 ? "BULLISH" : (bias < 0 ? "BEARISH" : "NEUTRAL")
color biasCol = bias > 0 ? thBull : (bias < 0 ? thBear : txtSub)

var table dash = table.new(position.top_right, 2, 8, border_width=1, bgcolor=bgHud, border_color=borderHud)
if barstate.islast
    table.cell(dash, 0, 0, "Liquidity Matrix EVO", text_color=txtMain, text_size=hudSize, text_font_family=font.family_monospace)
    table.merge_cells(dash, 0, 0, 1, 0)
    
    table.cell(dash, 0, 1, "Market Bias:", text_color=txtSub, text_size=hudSize)
    table.cell(dash, 1, 1, biasStr + " (" + str.tostring(biasStrength) + "/3)", text_color=biasCol, text_size=hudSize, text_font_family=font.family_monospace)
    
    table.cell(dash, 0, 2, "Closest Res:", text_color=txtSub, text_size=hudSize)
    table.cell(dash, 1, 2, not na(closestRes) ? str.tostring(closestRes.price, format.mintick) : "N/A", text_color=thBear, text_size=hudSize, text_font_family=font.family_monospace)
    
    table.cell(dash, 0, 3, "Closest Sup:", text_color=txtSub, text_size=hudSize)
    table.cell(dash, 1, 3, not na(closestSup) ? str.tostring(closestSup.price, format.mintick) : "N/A", text_color=thBull, text_size=hudSize, text_font_family=font.family_monospace)

    string probTxt = "WAITING"
    color probCol = txtSub
    if not na(closestRes) and not na(closestSup)
        [distToRes, _1] = getDistanceToZone(closestRes.price)
        [distToSup, _2] = getDistanceToZone(closestSup.price)
        totalDist = distToRes + distToSup
        if totalDist > 0
            probToRes = (distToSup / totalDist) * 100
            probToSup = (distToRes / totalDist) * 100
            if bias > 0
                probToRes := probToRes * 1.2
                probToSup := probToSup * 0.8
            else if bias < 0
                probToRes := probToRes * 0.8
                probToSup := probToSup * 1.2
            total = probToRes + probToSup
            probTxt := "↑" + str.tostring((probToRes/total)*100, "#.#") + "% | ↓" + str.tostring((probToSup/total)*100, "#.#") + "%"
            probCol := (probToRes > probToSup) ? thBull : thBear

    table.cell(dash, 0, 4, "Hit Vector:", text_color=txtSub, text_size=hudSize)
    table.cell(dash, 1, 4, probTxt, text_color=probCol, text_size=hudSize, text_font_family=font.family_monospace)

    table.cell(dash, 0, 5, "Zone Class:", text_color=txtSub, text_size=hudSize)
    table.cell(dash, 1, 5, "🛡️ " + str.tostring(wallZones) + " | ⏳ " + str.tostring(evoZones) + " | ⚠️ " + str.tostring(weakZones), text_color=txtMain, text_size=hudSize, text_font_family=font.family_monospace)

    table.cell(dash, 0, 6, "Active Zones:", text_color=txtSub, text_size=hudSize)
    table.cell(dash, 1, 6, str.tostring(array.size(activeZones)), text_color=txtMain, text_size=hudSize, text_font_family=font.family_monospace)

    table.merge_cells(dash, 0, 7, 1, 7)
    color sigBg = isLight ? color.new(color.black, 90) : color.new(color.black, 70)
    table.cell(dash, 0, 7, "Created by H33RNAN", text_color=thSweep, bgcolor=sigBg, text_size=size.tiny, text_font_family=font.family_monospace, text_halign=text.align_center)

Overview

Zones carry an age label, and sweeps of a wick are shown and removed once price crosses back. A small heads-up panel shows a distance-based estimate of the nearest resistance versus support. Inputs cover swing length, zone limits, tolerance, clustering, volume weighting and visual theme. Labels and settings are in Spanish.

Details

Published by

h33rnan on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

SMC / ICT / price action, Support & resistance

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
Tema VisualstringArticthemeChoice
☀️ Modo ClaroboolfalseisLight
Tamaño del PanelstringSmallhudSizeInput
Longitud Swingint10swingLength
Fuerza Mínimaint2liqStrength
Extensión Líneasint50extendBars
Velas de Análisis Históricoint300lookbackBars
Vida Máxima de Zona (Velas)int3000maxZoneAge
Límite de Zonas Activasint150maxZonesRender
Tolerancia %float0.3tolerancePct
Agrupación de Zonas %float0.5clusterDistance
Peso del Volumenfloat1.5volumeWeight
Show all 16 settings
SettingTypeDefaultVariable
Peso de Rechazosfloat2.0rejectionWeight
Sensibilidad de Mechasfloat0.3wickStrength
Analizar VolumenbooltrueuseVolumeAnalysis
Detectar Trampas (Sweeps)booltruedetectLiquidityGrabs
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
218 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 indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers