Indicator · Pine Script v6 · On the chart

Liquidity Zones

by MarcosACH· code credited to ActiveQuants

Liquidity Zones highlights bars where volume is above a multiple of its moving average while short-term price volatility is below half of the average volatility.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code72
Settings10inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago8 Jul 2025

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

72 lines of Pine Script v6 from liquidity_zones.pinescript, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

liquidity_zones.pinescript
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ActiveQuants
// Created by ActiveQuants
// Last updated: March 15, 2025

//@version=6
indicator(title = "Liquidity Zones [ActiveQuants]", overlay = true, max_labels_count = 500)
import MarcosACH/CandleAnalysis/1 as CndlA

//#region ------ USER INPUTS
color liquidityZonesColor = input.color(defval = color.new(color.orange, 70), title = "Liquidity Zones Color")
int volLength = input.int(defval = 20, title = "Volume SMA Length")
float volMultiplier = input.float(defval = 2.0, title = "Volume Threshold Multiplier", tooltip = "This multiplies the volume SMA.")
int volatilityLength = input.int(defval = 14, title = "Price Std. Dev. Length", tooltip = "Length for calculating the closing price standard deviation, used to measure average volatility.")
bool plotZoneVolume = input.bool(defval = true, title = "Zone Volume", inline = "volume")
string volumeMeasurement = input.string(defval = "Units", title = "", options = ["Units", "Currency Value"], inline = "volume")
string volumeLabelSize = input.string(defval = size.small, title = "", options = [size.auto, size.tiny, size.small, size.normal, size.large, size.huge], inline = "volume")
bool mergeConsecutiveZones = input.bool(defval = true, title = "Merge Consecutive Zones", tooltip = "When enabled, volumes from consecutive liquidity zones are summed into a single total, and only the most recent label is displayed (previous labels in the sequence are removed).")
int showLast = input.int(defval = 500, title = "Show Last", minval = 10, step = 10, tooltip = "Number of bars back the indicator can plot.")
string timeframe = input.timeframe(defval = "", title = "Timeframe")
//#endregion

//#region ----- VARIABLES
bool highVol = false
bool liquidityZone = false
float vol = na
bool ltfLowVolatilityTrigger = false
//#endregion

//#region ----- CALCULATIONS
showLast := math.round(showLast * (timeframe.in_seconds(timeframe.period) / timeframe.in_seconds(timeframe)))

float htfVol = request.security(syminfo.tickerid, timeframe, volume, calc_bars_count = math.max(1, showLast))
float htfAvgVol = request.security(syminfo.tickerid, timeframe, ta.sma(volume, volLength), calc_bars_count = math.max(1, showLast))

array<float> ltfVol = request.security_lower_tf(syminfo.tickerid, timeframe, volume, ignore_invalid_timeframe = true, calc_bars_count = math.max(1, showLast))
array<float> ltfAvgVol = request.security_lower_tf(syminfo.tickerid, timeframe, ta.sma(volume, volLength), ignore_invalid_timeframe = true, calc_bars_count = math.max(1, showLast))

float htfAvgVolatility = request.security(syminfo.tickerid, timeframe, ta.stdev(close, volatilityLength), calc_bars_count = math.max(1, showLast))
bool htfLowVolatility = request.security(syminfo.tickerid, timeframe, ta.stdev(close, 5), calc_bars_count = math.max(1, showLast)) < htfAvgVolatility * 0.5

array<float> ltfAvgVolatility = request.security_lower_tf(syminfo.tickerid, timeframe, ta.stdev(close, volatilityLength), ignore_invalid_timeframe = true, calc_bars_count = math.max(1, showLast))
array<float> ltfLowVolatility = request.security_lower_tf(syminfo.tickerid, timeframe, ta.stdev(close, 5), ignore_invalid_timeframe = true, calc_bars_count = math.max(1, showLast))
if not na(ltfAvgVolatility) and ltfAvgVolatility.size() > 0 and not na(ltfLowVolatility) and ltfLowVolatility.size() > 0
    ltfLowVolatilityTrigger := ltfLowVolatility.last() < ltfAvgVolatility.last() * 0.5

if timeframe.in_seconds(timeframe) >= timeframe.in_seconds(timeframe.period)
    highVol := htfVol > htfAvgVol * volMultiplier
    liquidityZone := highVol and htfLowVolatility and barstate.isconfirmed
    vol := volumeMeasurement == "Currency Value" ? htfVol * close : htfVol
else if timeframe.in_seconds(timeframe) < timeframe.in_seconds(timeframe.period) and ltfVol.size() > 0 and ltfAvgVol.size() > 0
    highVol := ltfVol.last() > ltfAvgVol.last() * volMultiplier
    liquidityZone := highVol and ltfLowVolatilityTrigger and barstate.isconfirmed
    vol := volumeMeasurement == "Currency Value" ? ltfVol.last() * close : ltfVol.last()

int consecutiveZones = ta.barssince(not liquidityZone)
vol := math.sum(vol, mergeConsecutiveZones and liquidityZone ? consecutiveZones : 1)
//#endregion

//#region ----- PLOTTING
bgcolor(liquidityZone ? liquidityZonesColor : na, title = "Liquidity Zones")

if liquidityZone and plotZoneVolume
    label labels = label.new(bar_index, CndlA.isBullish() or CndlA.isBE() ? low : high, str.tostring(vol, format.volume), yloc = CndlA.isBullish() or CndlA.isBE() ? yloc.belowbar : yloc.abovebar, color = na, textcolor = CndlA.isBullish() or CndlA.isBE() ? #089981 : #ff5252, size = volumeLabelSize)
    if mergeConsecutiveZones and consecutiveZones > 1
        for i = 1 to consecutiveZones - 1
            label.delete(labels[consecutiveZones - i])
//#endregion

//#region ----- ALERTS
alertcondition(liquidityZone, "Liquidity Zone", "High-volume and low-volatility zone detected!")
//#endregion

Overview

Matching bars are shaded as zones, with optional labels showing the zone volume in units or currency value. Consecutive zones can be merged, and an alert fires when a zone is detected. A separate timeframe can be chosen, and the number of recent bars shown is configurable. It draws on the price chart.

Details

Published by

MarcosACH on GitHub

Code credit

ActiveQuants, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volume, Support & resistance, Volatility & bands

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.

Topics

pinescriptpinescript-indicatorstrading-algorithmstrading-indicatorstradingvewtechnical-analysistechnical-analysis-indicatorstradingviewpinescript-algorithms

Settings

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

SettingTypeDefaultVariable
Liquidity Zones Colorcolorcolor.new(color.orange, 70)liquidityZonesColor
Volume SMA Lengthint20volLength
Volume Threshold Multiplierfloat2.0volMultiplier
Price Std. Dev. Lengthint14volatilityLength
Zone VolumebooltrueplotZoneVolume
volumeMeasurementstringUnitsvolumeMeasurement
volumeLabelSizestringsize.smallvolumeLabelSize
Merge Consecutive ZonesbooltruemergeConsecutiveZones
Show Lastint500showLast
Timeframetimeframetimeframe
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

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

VWAP - Basic

by TradersPost
218 stars

VWAP - Basic plots an anchored Volume Weighted Average Price directly on the main price chart alongside two standard deviation bands. It calculates typical price weighted by volume, resetting the cumulative calculations at user-selected session, weekly, or mon

Indicator v6 VolumeSupport & resistance
Updated 3 months ago · None stated GitHub repository of VWAP - Basic

D/W/M VWAPs

by cryptorife
75 stars

This indicator plots daily, weekly, and monthly volume-weighted average prices on the price chart, using a selectable source that defaults to hlc3. For each enabled period it also draws two standard-deviation bands around the VWAP, with multipliers defaulting

Indicator v4 VolumeVolatility & bands
Updated 3 years ago · GPL-3.0 GitHub repository of D/W/M VWAPs

LoD Intraday Entry

by ChartsLector
41 stars

This overlay indicator marks the current day's low and a suggested entry zone a fraction of daily ATR below that low. It compares daily volume with a volume moving average, plots daily SMA and EMA distance, and draws an optional ATR-width price cloud. Labels c

Indicator v6 Support & resistanceVolatility & bands
Updated 3 days ago · None stated GitHub repository of LoD Intraday Entry
11 stars

This indicator identifies and visualizes key support and resistance zones directly on the price chart using historical 1-hour bar evidence. It calculates zone strength by weighting price rejections, support-resistance flips, relative volume spikes, price gaps,

Indicator v6 Support & resistanceVolatility & bands
Updated 7 weeks ago · MIT GitHub repository of 1-Hour Key Level Heatmap

This overlay indicator marks Wyckoff-style buying and selling climaxes on the price chart. It filters trend with an exponential moving average and a higher-timeframe EMA, then flags accumulation or distribution when price and ATR sit relative to their swing av

Indicator v6 TrendVolatility & bands
Updated 1 year ago · MIT GitHub repository of Ultimate Wyckoff Indicator V3 (Refined)

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