OPEN-SOURCE SCRIPT

[ A L P H A X ] Dynamic Liquidity Matrix

8 270

AlphaX Dynamic Liquidity Matrix — Volume-Weighted Liquidity Heatmap, Fair Value Gap Overlay, Sweep Detection & Live Bias Dashboard

AlphaX Dynamic Liquidity Matrix is a professional-grade liquidity mapping system that identifies where stop-loss clusters and unfilled liquidity pools accumulate across the recent price range — and tracks them in real time. Unlike a static volume profile that simply measures historical volume at price, this indicator builds a fully dynamic heatmap from volume-weighted pivot extremes, recalculates on every bar, and only displays zones that price has not yet revisited. These are the active pockets that institutions and smart money systematically target for liquidity sweeps.

Built on the AlphaX brand framework, the indicator combines four distinct analytical layers: a dynamic liquidity profile, a Fair Value Gap (imbalance) overlay, a sweep detection engine, and a live market context dashboard — all unified under a single, clean visual system.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔬 The Dynamic Liquidity Profile — How It Works

Most volume profiles are passive historical tools. The AlphaX Dynamic Liquidity Matrix is active and forward-looking.

On every bar within your configured lookback window, the indicator identifies swing highs and swing lows and assigns each one a volume weight based on the smoothed cumulative volume at that moment — normalized against the maximum volume within the entire lookback window. This produces a volume score (0–100%) for every extreme, which represents the relative significance of the liquidity pool at that price.

These volume-weighted extremes are then distributed across a configurable number of price bins (resolution levels) spanning the full high-to-low range of the lookback window. Each bin accumulates the total volume from every pivot that maps into it. The result is a real-time heatmap profile showing exactly where liquidity is concentrated — heavier at some levels, lighter at others.

The ATR is used to scale the pivot offset distance dynamically, meaning the profile adapts automatically to the current volatility regime. On high-volatility instruments and timeframes, the pivot offsets expand; on quiet markets, they contract. No manual recalibration is required.

What makes this different from a standard Volume Profile:
  • Standard volume profiles measure how much volume traded at a price — they are backward-looking and include already-filled orders
  • AlphaX DLM tracks unmitigated pivot extremes — zones where stops and unfilled orders still exist because price has NOT revisited them since they formed
  • Every pivot that gets swept by price is automatically removed from the profile — keeping the map clean and relevant at all times
  • The profile rebuilds every bar, so it reflects the current state of the market's liquidity landscape, not a snapshot from hours or days ago


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📊 Profile Visualization

The profile is displayed as horizontal bars extending to the right of the current price, with each bar representing one price bin. The visual system communicates multiple layers of information simultaneously:

Color Logic
  • Yellow-green bars — bins where the current close is above the bin midpoint (buy-side liquidity / demand zones)
  • Red bars — bins where the current close is below the bin midpoint (sell-side liquidity / supply zones)
  • Orange highlight — the Point of Control (POC) bin, the single highest-volume level in the entire profile


Gradient Depth
Each bar uses a gradient that scales from near-transparent at low volume to fully opaque at high volume. At a glance, the most significant liquidity concentrations stand out immediately — no need to read numbers or hover over elements.

Volume Labels
For bins with above-average volume accumulation, the raw volume figure is displayed inside the bar. A percentage label on the left side of each bar shows what proportion of the maximum bin volume that level represents. This gives you both absolute and relative context for every zone.

POC Line
The Point of Control — the level with the highest accumulated liquidity in the profile — is marked with a full dashed horizontal line that extends across the entire lookback window. This makes it easy to see how price has historically reacted around the dominant liquidity level: rejected it, consolidated around it, or broken through it cleanly. A labeled marker on the right identifies the POC precisely.

Liquidity Level Lines
Each active bin above the noise floor is also represented by a dotted horizontal line on the chart itself. The line starts from the bar where price last tested that level and runs to the current bar, giving you a visual connection between the historical pivot origin and the current profile position. Line width scales with the bin's relative volume weight — heavier lines mean more significant zones.

Buy / Sell Split Mode
An optional split view separates each profile bar into its buy-side and sell-side components, stacked side by side. This lets you see at a single level whether it is dominated by buy-side stop clusters (below price), sell-side stop clusters (above price), or a balanced mix — critical for anticipating which direction a liquidity sweep is more likely to run.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Fair Value Gap (Imbalance) Overlay

A Fair Value Gap is a three-candle imbalance where the body of the middle candle is not overlapped by the wicks of the surrounding candles, creating a gap in price delivery. These gaps represent unfilled orders left by rapid, one-sided moves — and price has a strong statistical tendency to return to fill them.

AlphaX DLM detects and displays these gaps directly on the chart as shaded rectangular zones:

  • Bullish FVG — the low of the current candle is higher than the high of the candle two bars prior. Price moved up so quickly it left an unfilled gap below. Displayed in yellow-green.
  • Bearish FVG — the high of the current candle is lower than the low of the candle two bars prior. Price moved down so quickly it left an unfilled gap above. Displayed in red.


Mitigation Tracking
Once price returns and closes inside a FVG zone (mitigating it), the box is automatically removed from the chart. Only genuinely unmitigated gaps remain visible at all times — the overlay stays clean and actionable regardless of how many gaps have formed historically.

ATR-Scaled Minimum Size Filter
A configurable minimum FVG size (expressed as a multiple of the current ATR) filters out micro-gaps caused by normal spread or noise. Only structurally significant imbalances that represent real impulsive moves are displayed.

Background Highlight
When the current close is inside an active FVG zone — meaning price is currently sitting inside an unmitigated imbalance — the chart background highlights in a subtle amber tone. This is a real-time alert that price is at a decision point within institutional supply or demand.

How to trade FVGs with the Liquidity Matrix:
  • When a FVG aligns with a high-volume liquidity bin on the profile, the confluence is significant — two independent reasons for price to react at the same level
  • Bullish FVG zones near buy-side liquidity clusters are high-priority long re-entry areas
  • Bearish FVG zones near sell-side liquidity clusters are high-priority short re-entry areas
  • A sweep into a zone followed by an immediate close back through it (a sweep-and-reverse pattern) is one of the cleanest entry setups the indicator can flag


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🎯 Liquidity Sweep Detection

Liquidity sweeps are the mechanism by which institutional players clear stop-loss orders before reversing price in the opposite direction. Identifying sweeps in real time gives retail traders the opportunity to enter after the stops have been taken — in alignment with the direction the institution is positioning.

AlphaX DLM detects sweeps using the following logic:

Bullish Sweep (⚡ SWEEP LOW)
The current bar's low breaches the lowest low of the configurable sweep lookback window, but the bar closes above that low and closes as a bullish candle. This pattern indicates that sell-side stops below the recent range were triggered, absorbed, and reversed — a classic stop hunt before an upside move.

Bearish Sweep (⚡ SWEEP HIGH)
The current bar's high breaches the highest high of the sweep lookback window, but the bar closes below that high and closes as a bearish candle. Buy-side stops above the recent range were triggered and absorbed — a stop hunt before a downside move.

Visual Presentation
  • Bullish sweeps are labeled with a cyan "⚡ SWEEP LOW" marker below the sweep candle
  • Bearish sweeps are labeled with an orange "⚡ SWEEP HIGH" marker above the sweep candle
  • The sweep candle itself is barcolored in the respective sweep color — immediately visible on the chart without needing to look for the label
  • The most recent 20 sweep labels are retained on the chart, automatically pruning the oldest when new ones form


How to use Sweep Detection with the Liquidity Profile:
  • A sweep into a high-volume buy-side liquidity bin followed by a close back above that bin is a high-conviction long entry signal
  • A sweep into a high-volume sell-side liquidity bin followed by a close back below that bin is a high-conviction short entry signal
  • When a sweep coincides with a FVG zone AND a high-volume profile bin, the three-way confluence represents the highest quality trade setup the indicator can identify
  • The sweep lookback can be tightened (lower value) for more sensitive detection on fast-moving instruments, or widened for cleaner, less-frequent signals on slower timeframes


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📋 Live Market Context Dashboard

A compact real-time dashboard displays the current state of all indicator systems at a glance. It is divided into four sections:

Profile Section
  • Active Pivots — total number of unmitigated pivot extremes currently mapped in the profile. Higher counts indicate a richer, more complex liquidity landscape.
  • Buy Pivots — number of unmitigated buy-side (demand) extremes
  • Sell Pivots — number of unmitigated sell-side (supply) extremes
  • Liquidity Bias — overall directional lean of the liquidity map. BUY SIDE means more unmitigated demand zones exist; SELL SIDE means more supply zones exist; BALANCED means roughly equal. This is not a trade signal on its own, but it tells you where the more significant unfilled orders are positioned.


Sweep Section
  • Last Sweep — whether the current bar is a bullish or bearish sweep, highlighted in the respective sweep color when active
  • Sweep Lookback — the currently configured lookback window for sweep detection


Fair Value Gap Section
  • Active FVGs — total number of unmitigated fair value gaps currently displayed on the chart
  • FVG Split — the breakdown between active bullish and bearish FVGs. When bullish FVGs dominate, unmitigated demand imbalances outnumber supply imbalances — and vice versa.


Market Context Section
  • ATR — current ATR value and its percentage of price. Color-coded: green for low volatility, orange for moderate, red for elevated. High ATR readings mean liquidity zones will be wider and stops should be placed further from entry.
  • Normalized Volume — current volume expressed as a percentage of the maximum volume within the lookback window, labeled VERY HIGH / HIGH / NORMAL / LOW / VERY LOW. Elevated volume on a sweep candle significantly increases the probability of follow-through.
  • Price in Range — where the current close sits within the full liquidity range as a percentage, labeled as upper zone / mid-range / lower zone. This tells you at a glance whether price is approaching a range extreme (potential sweep target) or sitting in the middle of the distribution.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🚀 How to Identify Trade Opportunities — Step by Step

Step 1 — Assess the Liquidity Landscape
  • Load the indicator and check the profile: are liquidity bins densely clustered in a narrow zone, or spread across a wide range?
  • Check the Liquidity Bias in the dashboard: does the map lean buy-side or sell-side?
  • Identify the POC line — this is the dominant reference level for the session


Step 2 — Identify High-Value Target Zones
  • Look for thick profile bars with high volume percentages — these are the zones that price is most likely to revisit for a sweep
  • Note any FVG boxes that overlap with high-volume bins — these dual-layer confluences are the strongest setups
  • Mark the POC: if price is approaching from below with buy-side bias, the POC is a likely magnet. If approaching from above with sell-side bias, the same applies.


Step 3 — Wait for a Sweep into a Liquidity Zone
  • Watch for price to push into a high-volume bin — especially below a cluster of buy pivots or above a cluster of sell pivots
  • A sweep label (⚡ SWEEP LOW or ⚡ SWEEP HIGH) confirms the stop-hunt pattern has occurred
  • The sweep candle will be highlighted in cyan (bull sweep) or orange (bear sweep) for instant identification


Step 4 — Confirm the Reversal
  • The most important confirmation is the close: the sweep candle must close back on the opposite side of the liquidity zone it spiked through
  • If price is also inside a FVG zone and closes back out of it, the reversal confluence is stronger
  • Elevated normalized volume on the sweep candle (VERY HIGH or HIGH) significantly increases the conviction of the setup


Step 5 — Enter and Manage
  • Enter in the direction of the sweep reversal — long after a bullish sweep, short after a bearish sweep
  • Place your stop loss below the sweep wick low (for longs) or above the sweep wick high (for shorts) — the stop hunt has already occurred, so price should not need to revisit that level
  • Target the POC level, the next high-volume bin on the profile, or the opposite side of an active FVG zone
  • If the Liquidity Bias matches your trade direction (e.g., BUY SIDE bias on a long trade), hold with greater conviction — the overall liquidity landscape supports continuation


Step 6 — When NOT to Trade
  • If the profile is extremely thin (very few active pivots), the liquidity landscape is unclear — wait for the profile to rebuild
  • If the ATR is very low (quiet, compressed market), FVGs and sweep signals may be less reliable — tighten the FVG minimum size filter
  • If price is in mid-range with BALANCED bias and no nearby FVGs, there is no clear structural edge — wait for price to approach a zone with confluence
  • Do not chase a sweep candle — the entry is on the confirmation close, not the spike


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Settings Reference

Core Settings
  • Lookback Bars — how many bars back the indicator scans for pivot extremes and builds the liquidity profile (default: 300). Increase for a broader, more historical view; decrease for a tighter, more immediate profile focused on the current session.
  • Profile Resolution — the number of price bins the range is divided into (default: 50). Higher values give finer granularity; lower values produce a smoother, broader profile. Recommended range: 30–70.
  • Volume Smoothing — the rolling sum window for volume normalization (default: 10). Higher values reduce the effect of individual volume spikes; lower values make the profile more reactive to each candle's volume.
  • ATR Length — the lookback period for the ATR calculation used to scale pivot offsets (default: 14). Match this to your typical ATR analysis setting.


Profile Display
  • Show Profile Bars — toggle the horizontal heatmap bars on/off
  • Show Volume % Labels — toggle volume figures and percentage labels inside and beside each bar
  • Show POC Line — toggle the full-width dashed POC level line and label
  • Show Liquidity Level Lines — toggle the dotted horizontal lines connecting each pivot's origin to the current bar
  • Split Buy / Sell Bars — splits each profile bar into its buy-side and sell-side volume components displayed side by side
  • Bar Offset from Price — controls the gap between the current bar and where the profile starts rendering (default: 20 bars). Increase if the profile overlaps with recent candles.
  • Max Bar Width — controls the maximum horizontal length of the widest profile bar in bars (default: 50). Adjust based on your chart's zoom level.


Fair Value Gaps
  • Show Fair Value Gaps — toggle the FVG overlay on/off
  • Min FVG Size (ATR mult) — minimum gap size as a multiple of ATR for a gap to qualify as a valid FVG (default: 0.1×). Increase to filter out minor imbalances; decrease to show all gaps.
  • Max FVGs to Display — maximum number of unmitigated FVGs shown simultaneously (default: 8). Oldest gaps are pruned first when the limit is reached.


Sweep Detection
  • Highlight Sweeps — toggle sweep labels and candle barcolor on/off
  • Sweep Lookback (bars) — the window used to define the recent high/low for sweep detection (default: 5). Lower values detect micro-sweeps on fast instruments; higher values detect only significant structural sweeps.


Colors
  • Buy Liquidity — color for buy-side profile bars and bullish FVGs (default: yellow-green #c8e624)
  • Sell Liquidity — color for sell-side profile bars and bearish FVGs (default: red #ff1744)
  • POC / Max Level — color for the Point of Control bar, POC line, and FVG background highlight (default: orange #ff9800)
  • Sweep Bull Label — color for bullish sweep labels and barcolor (default: cyan #00e5ff)
  • Sweep Bear Label — color for bearish sweep labels and barcolor (default: orange #ff9100)
  • Dashboard Background / Text / Neutral — dashboard theme colors


Dashboard
  • Show Dashboard — toggle the live context dashboard on/off
  • Position — choose Top Left, Top Right, Bottom Left, or Bottom Right
  • Text Size — Tiny, Small, or Normal


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔔 Alert Conditions

  • Bullish Liquidity Sweep — fires when a bullish sweep pattern is confirmed on bar close
  • Bearish Liquidity Sweep — fires when a bearish sweep pattern is confirmed on bar close
  • Any Liquidity Sweep — fires on either sweep direction — use for a single catch-all alert
  • Bullish FVG Created — fires when a new unmitigated bullish fair value gap forms
  • Bearish FVG Created — fires when a new unmitigated bearish fair value gap forms
  • Price Entered FVG — fires when the current close moves inside any active unmitigated FVG zone


All alert messages include {{ticker}} and {{interval}} placeholders for clean webhook and bot integration.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Key Features

  • 🔬 Fully dynamic volume-weighted liquidity heatmap — rebuilds every bar, not a static historical snapshot
  • 🗑 Auto-removal of swept/mitigated pivot levels — the profile always reflects only active, unvisited liquidity
  • 📊 ATR-adaptive pivot offsets — automatically scales to the current volatility regime, no manual recalibration
  • 🟡 Volume-gradient profile bars with buy/sell split mode — see the composition of every liquidity zone
  • ◆ POC full-width level line with label — the dominant liquidity reference level clearly marked at all times
  • ⚡ Fair Value Gap overlay with real-time mitigation tracking — only unmitigated imbalances remain visible
  • 🌐 FVG background highlight — instant visual alert when price is sitting inside an active imbalance
  • 🎯 Liquidity sweep detection with barcolor — cyan for bull sweeps, orange for bear sweeps
  • 📋 Live dashboard — active pivots, buy/sell count, liquidity bias, sweep status, FVG split, ATR, normalized volume, and price-in-range percentage
  • 🎨 Full AlphaX brand theme — yellow-green / red / orange / dark background, consistent with the AlphaX indicator suite
  • 🔔 6 alert conditions — sweep entries and FVG events with clean ticker/interval message formatting
  • ⚙ Fully configurable — all lookback windows, resolution, sensitivity, colors, and display toggles adjustable from the settings panel


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

👥 Who This Is For

  • 🥇 Smart Money Concept (SMC) traders — the entire indicator is built around the core SMC concepts of liquidity pools, stop hunts, and fair value gaps. It automates the manual process of mapping where stops are likely clustered and where imbalances need to be filled.
  • 📊 Order flow and volume profile traders — the dynamic heatmap provides a volume-at-price context that updates in real time, giving a live picture of the market's liquidity distribution.
  • Intraday scalpers and day traders — the sweep detection and FVG alerts fire on bar close, making them practical for fast timeframe traders on instruments like XAUUSD, indices, and forex majors.
  • 🧠 Traders who struggle with entry timing — the sweep reversal pattern gives a precise, rules-based entry trigger rather than a subjective "it looks good" decision.
  • 📈 Traders who want confluence, not single indicators — when a sweep, a high-volume bin, and a FVG all align at the same level, the three-layer confluence removes ambiguity and provides an objective framework for decision-making.
  • 🎯 Traders building systematic approaches — all signals are rule-based, non-repainting, and confirmed on bar close. The dashboard provides quantitative context — not just visuals — for every condition the indicator monitors.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📝 Notes

  • All signals are non-repainting — every sweep label, FVG box, and profile bar is confirmed on bar close and does not move or disappear retroactively
  • The profile renders only at the last bar (barstate.islast) and redraws on each new bar — this is by design and standard practice for all right-side profile indicators. Historical profile positions are not stored.
  • On very low timeframes (sub-1-minute) or extended chart history windows, TradingView's 500-box and 500-line limits apply — the indicator operates within these limits by design. Reducing the lookback or bins will always keep rendering within limits.
  • The ATR-adaptive offset means the indicator self-adjusts across different instruments and timeframes without requiring separate configurations for each. The same settings work on XAUUSD 1-minute and EURUSD 15-minute with no manual changes needed.
  • For best results, use in combination with AlphaX Vision (Fusion Trend Engine) — the Liquidity Matrix identifies where to enter within the zones that Vision's trend system defines as directionally favored.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Disclaimer

This indicator is a technical analysis and visualization tool intended for educational and informational purposes only. It does not constitute financial advice or a recommendation to buy or sell any financial instrument. All signals are generated from historical and real-time price data using mathematical calculations — their accuracy or profitability is not guaranteed. Past performance of any signal type does not guarantee future results. Always conduct your own analysis, use proper risk management, and consult a licensed financial advisor before making any trading decisions. The author accepts no responsibility for any losses incurred from the use of this indicator.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Built for traders who read the market at the level where institutions operate.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน