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.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
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.
Swing liquidity zones classified by age and strength
Sweep detection that clears a sweep once price re-crosses
Zone age labels and rejection-based line styling
On-chart panel with nearest resistance and support estimate
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Tema Visual
string
Artic
themeChoice
☀️ Modo Claro
bool
false
isLight
Tamaño del Panel
string
Small
hudSizeInput
Longitud Swing
int
10
swingLength
Fuerza Mínima
int
2
liqStrength
Extensión Líneas
int
50
extendBars
Velas de Análisis Histórico
int
300
lookbackBars
Vida Máxima de Zona (Velas)
int
3000
maxZoneAge
Límite de Zonas Activas
int
150
maxZonesRender
Tolerancia %
float
0.3
tolerancePct
Agrupación de Zonas %
float
0.5
clusterDistance
Peso del Volumen
float
1.5
volumeWeight
Show all 16 settings
Setting
Type
Default
Variable
Peso de Rechazos
float
2.0
rejectionWeight
Sensibilidad de Mechas
float
0.3
wickStrength
Analizar Volumen
bool
true
useVolumeAnalysis
Detectar Trampas (Sweeps)
bool
true
detectLiquidityGrabs
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.
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
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
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
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
Indicatorv6SMC / ICT / price actionSessions & time
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
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