Indicator · Pine Script v6 · On the chart

Adaptive Liquidity Matrix

by h33rnan

The Adaptive Liquidity Matrix indicator calculates and plots a synthetic liquidity matrix on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code142
Settings9inputs
LicenceAGPL-3.0
Last update6 months ago12 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

142 lines of Pine Script v6 from Adaptive-Liquidity-Matrix.pine, published under AGPL-3.0. Keep the author's credit and licence lines when you reuse it.

Adaptive-Liquidity-Matrix.pine
//@version=6
indicator("Adaptive Liquidity Matrix", overlay=true, max_boxes_count=500, max_labels_count=500, max_lines_count=500)

// ═══════════════════════════════════════════════════════════════════════════════
// 1. INPUTS TÁCTICOS (MOTOR MATEMÁTICO)
// ═══════════════════════════════════════════════════════════════════════════════
grp_sys = 'Matrix Core Engine'
grid_mode = input.string("Fibonacci (MTF ATR)", title="Grid Expansion Mode", options=["Fibonacci (MTF ATR)", "Legacy Linear"], group=grp_sys)
tf_selection = input.timeframe("D", title="Macro Anchor Timeframe", group=grp_sys)
lookback_length = input.int(200, title="Volume Lookback (Bars)", minval=1, group=grp_sys)
fib_mult = input.float(3.0, title="Fibonacci Volatility Multiplier", minval=0.1, step=0.5, tooltip="Ajusta la amplitud macro de la red de Fibonacci", group=grp_sys)

// ═══════════════════════════════════════════════════════════════════════════════
// 2. ESTÉTICA QUIRÚRGICA & UI (USER DEFINED BLOCK)
// ═══════════════════════════════════════════════════════════════════════════════
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, "☀️", group=G_THEME)
string hudSizeInput = input.string("Small", "Tamaño del Panel", options=["Tiny", "Small", "Normal", "Large"], group=G_THEME)
string hudPosInput = input.string("Bottom Right", "Posición del HUD", options=["Bottom Right", "Bottom Left", "Top Right", "Top Left"], group=G_THEME)
float zone_height_pct = input.float(0.15, "Amplitud de Zona (%)", minval=0.01, step=0.05, group=G_THEME)

string hudSize = hudSizeInput == "Tiny" ? size.tiny : hudSizeInput == "Small" ? size.small : hudSizeInput == "Normal" ? size.normal : size.large
string hud_pos = hudPosInput == "Bottom Right" ? position.bottom_right : hudPosInput == "Bottom Left" ? position.bottom_left : hudPosInput == "Top Right" ? position.top_right : position.top_left

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(#5d5e63, 30) : color.rgb(249, 250, 252)

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

// Adaptación de Transparencia para las Cajas
color col_sup = color.new(thBear, 85)
color col_dem = color.new(thBull, 85)
color col_ghost = isLight ? color.new(#e0e0e0, 70) : color.new(#1a1a1a, 80)
color txt_box = color.new(txtMain, 30)

pip = syminfo.mintick * 10
var float[] fibs = array.from(0.236, 0.382, 0.618, 1.000, 1.618, 2.618, 4.236, 6.854)

// ═══════════════════════════════════════════════════════════════════════════════
// 3. EXTRACCIÓN GENÉTICA MACRO (MTF POLARITY ENGINE)
// ═══════════════════════════════════════════════════════════════════════════════
f_macro_data(_len) =>
    idx = ta.highestbars(volume, _len)
    a_idx = math.abs(idx)
    _atr = ta.atr(14)
    [open[a_idx], high[a_idx], low[a_idx], close[a_idx], _atr[a_idx]]

[m_open, m_high, m_low, m_close, m_atr] = request.security(syminfo.tickerid, tf_selection, f_macro_data(lookback_length))

bool is_bull_anchor = m_close >= m_open
float macro_anchor = is_bull_anchor ? m_low : m_high

// ═══════════════════════════════════════════════════════════════════════════════
// 4. GENERACIÓN DE MATRIZ Y GHOSTING (OFFSET 10 BARRAS)
// ═══════════════════════════════════════════════════════════════════════════════
var box[] grid_boxes = array.new_box()
var float closest_supply = na
var float closest_demand = na

if barstate.islast
    float[] final_levels = array.new_float()
    
    if array.size(grid_boxes) > 0
        for b in grid_boxes
            box.delete(b)
        array.clear(grid_boxes)

    if grid_mode == "Fibonacci (MTF ATR)"
        if not na(macro_anchor) and not na(m_atr)
            for f in fibs
                float offset = f * m_atr * fib_mult
                array.push(final_levels, macro_anchor + offset) 
                array.push(final_levels, macro_anchor - offset) 
    else
        float[] raw_legacy = array.from(50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 400.0, 500.0, 600.0, 800.0)
        float scale = macro_anchor / 500.0 
        for r in raw_legacy
            array.push(final_levels, macro_anchor + (r * scale))
            array.push(final_levels, macro_anchor - (r * scale))

    closest_supply := 9999999.9
    closest_demand := 0.0

    if array.size(final_levels) > 0
        for i = 0 to array.size(final_levels) - 1
            float lvl = array.get(final_levels, i)
            float h_val = lvl * (zone_height_pct / 100)
            float top_b = lvl + (h_val / 2)
            float btm_b = lvl - (h_val / 2)
            
            bool is_sup = lvl > macro_anchor
            bool is_mitigated = is_sup ? (close > top_b) : (close < btm_b)
            
            color bg_c = is_mitigated ? col_ghost : (is_sup ? col_sup : col_dem)
            color bd_c = color.new(bg_c, 50)
            string t_lbl = is_sup ? "SUPPLY | " + str.tostring(lvl, format.mintick) : "DEMAND | " + str.tostring(lvl, format.mintick)
            
            if not is_mitigated
                if is_sup and lvl < closest_supply
                    closest_supply := lvl
                if not is_sup and lvl > closest_demand
                    closest_demand := lvl

            // DESPLAZAMIENTO APLICADO: left = bar_index - 10
            bx = box.new(left = bar_index - 10, top = top_b, right = bar_index + 10, bottom = btm_b, border_color = bd_c, bgcolor = bg_c, extend = extend.right, text = t_lbl, text_size = size.tiny, text_color = is_mitigated ? color.new(txtMain, 80) : txt_box, text_halign = text.align_right, text_valign = text.align_center)
            array.push(grid_boxes, bx)

// ═══════════════════════════════════════════════════════════════════════════════
// 5. HUD TÁCTICO (TELEMETRÍA DE RED SINTÉTICA)
// ═══════════════════════════════════════════════════════════════════════════════
var table hud = table.new(hud_pos, 3, 4, border_width=1, border_color=borderHud, bgcolor=bgHud)

if barstate.islast
    string s_dist = na(closest_supply) or closest_supply == 9999999.9 ? "MITIGATED" : str.tostring(math.round((closest_supply - close) / pip, 1)) + " pips"
    string d_dist = na(closest_demand) or closest_demand == 0.0 ? "MITIGATED" : str.tostring(math.round((close - closest_demand) / pip, 1)) + " pips"

    color pol_col = is_bull_anchor ? thBull : thBear
    string pol_txt = is_bull_anchor ? "BULLISH (LOW)" : "BEARISH (HIGH)"

    table.cell(hud, 0, 0, "[ ADAPTATIVE LIQUIDITY MATRIX ]", text_color=txtMain, text_size=hudSize, text_halign=text.align_left, text_font_family=font.family_monospace)
    table.cell(hud, 1, 0, "", text_color=txtMain) 
    table.cell(hud, 2, 0, "CREATED BY H33RNAN", text_color=txtSub, text_size=hudSize, text_halign=text.align_right, text_font_family=font.family_monospace)
    
    table.cell(hud, 0, 1, "ANCHOR: " + str.tostring(macro_anchor, format.mintick), text_color=txtSub, text_size=hudSize, text_halign=text.align_left, text_font_family=font.family_monospace)
    table.cell(hud, 1, 1, " | ", text_color=txtSub, text_size=hudSize, text_halign=text.align_center)
    table.cell(hud, 2, 1, "POLARITY: " + pol_txt, text_color=pol_col, text_size=hudSize, text_halign=text.align_right, text_font_family=font.family_monospace)

    table.cell(hud, 0, 2, "MODE: " + grid_mode, text_color=color.new(#ffcc02, 0), text_size=hudSize, text_halign=text.align_left, text_font_family=font.family_monospace)
    table.cell(hud, 1, 2, " | ", text_color=txtSub, text_size=hudSize, text_halign=text.align_center)
    table.cell(hud, 2, 2, "MACRO ATR: " + str.tostring(m_atr, format.mintick), text_color=txtSub, text_size=hudSize, text_halign=text.align_right, text_font_family=font.family_monospace)

    table.cell(hud, 0, 3, "NEXT SUPPLY: " + s_dist, text_color=thBear, text_size=hudSize, text_halign=text.align_left, text_font_family=font.family_monospace)
    table.cell(hud, 1, 3, " | ", text_color=txtSub, text_size=hudSize, text_halign=text.align_center)
    table.cell(hud, 2, 3, "NEXT DEMAND: " + d_dist, text_color=thBull, text_size=hudSize, text_halign=text.align_right, text_font_family=font.family_monospace)

Overview

Adaptive Liquidity Matrix anchors to the highest volume candle on a selected macro timeframe, reads its polarity to set support or resistance levels, and expands the matrix using Fibonacci ratios scaled by the ATR volatility of that timeframe. Touched zones lose strength and ghost in the HUD when price closes through them. Settings control grid expansion mode, macro anchor timeframe, volume lookback, Fibonacci multiplier, visual theme, HUD size and position. It draws boxes, lines and labels directly on the price chart as a visualization tool with no entry or exit rules.

Details

Published by

h33rnan on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volatility & bands, Support & resistance, Volume, SMC / ICT / price action

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
Grid Expansion ModestringFibonacci (MTF ATR)grid_mode
Macro Anchor TimeframetimeframeDtf_selection
Volume Lookback (Bars)int200lookback_length
Fibonacci Volatility Multiplierfloat3.0fib_mult
Tema VisualstringArticthemeChoice
☀️boolfalseisLight
Tamaño del PanelstringSmallhudSizeInput
Posición del HUDstringBottom RighthudPosInput
Amplitud de Zona (%)float0.15zone_height_pct
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

Deep Trades Whales v4

by shubhamtaywade82
1 stars

Deep Trades Whales v4 is an indicator that detects large institutional trades by analyzing volume spikes against historical percentiles and Z-scores. It identifies whale activity through iceberg absorption patterns that require proximity to prior swing highs o

Indicator v6 VolumeVolatility & bands Archived
Updated 5 months ago · None stated GitHub repository of Deep Trades Whales v4

ICT Liquidity Void Fill

by ArunKBhaskar
575 stars

This overlay indicator marks ICT liquidity void fills on the price chart and can show long and short signals. It places a Fibonacci level inside a displacement candle, defaulting to the midpoint, and draws lines in a chosen style. Optional filters limit the fi

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Liquidity Void Fill

Snag - VWAP

by dearvn
257 stars

This indicator plots a custom Anchored Volume-Weighted Average Price (VWAP) directly on the price chart along with optional standard deviation bands. Users can anchor the VWAP to standard time periods like sessions, weeks, or months, or to corporate events suc

Indicator v5 Moving averagesVolatility & bands Repaints
Updated 6 weeks ago · None stated GitHub repository of Snag - VWAP
218 stars

This indicator maps market structure and supply and demand zones on the price chart. It marks validated and optional unvalidated swing highs and lows using a pivot length and extra confirmation bars. Consolidation and impulse moves are measured against ATR to

Indicator v6 SMC / ICT / price actionSupport & resistance Repaints
Updated 3 months ago · None stated GitHub repository of Market Structure + Supply/Demand

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