Liquidity Sweep Indicator — Free Pine Script v6 for TradingView
- liquidity-sweep-indicator.pine — the complete Pine Script v6 source
- README-FIRST.md — what it does and how to install it
- FREE-LICENSE.md — the free-edition license terms
About this product
Liquidity Sweep Indicator is a free Pine Script v6 indicator by Script Master Labs. It marks liquidity pools (confirmed pivot highs and lows) and the bars that sweep them and close back inside. The complete source is printed in full on this page and in the free download — paste it into TradingView's Pine Editor and it runs on TradingView's free plan. No payment, no account, no subscription.
What it computes, in its own terms: it liquidity sweeps under one explicit mechanical definition: liquidity pools are confirmed pivot highs and lows, and a sweep is a bar whose wick crosses a pool level but whose close returns back inside it. 'Liquidity' names resting orders inferred from swing points — the tool cannot observe actual orders, stops, or any participant's positions — and every pool appears pivot-length bars late, the disclosed price of not repainting.
How to use it
Open TradingView's Pine Editor, create a new blank script, paste the source, save, and click Add to chart. Adjust the inputs from the gear icon. The full source is printed on this page below, and the free download carries the same source file with an install README and the free-edition license.
Free edition vs paid edition
The script file is the complete indicator — the same Pine Script v6 source sold in the paid edition (https://dual.scriptmasterlabs.com/product/liquidity-sweep-indicator, $19 one-time). The paid edition adds the full written user guide, the evidence receipt, and the licensing and security reviews. Nothing in the script is held back from the free edition.
More free tools — free Pine Script v6 indicators and strategies, free trading calculators and a free x402 pre-payment trust check — are collected on the Free Tools hub. Educational software, not financial advice: it measures and draws a stated rule; it does not predict price and shows no win rate.
The complete Pine Script v6 source — free, on this page
Liquidity Sweep Indicator is a free Pine Script v6 indicator by Script Master Labs. It marks liquidity pools (confirmed pivot highs and lows) and the bars that sweep them and close back inside. The complete source is printed in full on this page and in the free download — paste it into TradingView's Pine Editor and it runs on TradingView's free plan. No payment, no account, no subscription.
// © 2026 Script Master Labs LLC — Liquidity Sweep Indicator for TradingView
// Research-based, original SML engineering. This indicator MARKS liquidity
// sweeps under one explicit, mechanical definition (below). "Liquidity" in
// this product's name names resting orders INFERRED from swing points — the
// popular charting assumption that stops and pending orders cluster beyond
// obvious swing highs and lows. The tool cannot observe actual orders,
// stops, or any participant's positions; nothing on the chart shows who
// traded or why. It makes no prediction and no profitability claim.
//@version=6
indicator("SML Liquidity Sweep Indicator", shorttitle = "SML Liquidity Sweep", overlay = true, max_lines_count = 500, max_labels_count = 500)
// ── The mechanical definition used by this indicator ────────────────────────
// Liquidity pool: a CONFIRMED pivot high or pivot low. A pivot is confirmed
// only `pivotLen` bars after the pivot bar (ta.pivothigh / ta.pivotlow with
// left = right = pivotLen), so every pool appears on the chart pivotLen bars
// late — that confirmation lag is the price of not repainting, and it is
// disclosed here and in the guide rather than hidden. Each confirmed pivot
// creates one pool: a short horizontal line at the pivot price, extending
// right. At most `maxPools` pools per side are kept; the oldest is removed
// first.
// SWEEP UP (liquidity grabbed above): a bar whose HIGH exceeds an active
// pool-high level but whose CLOSE is back BELOW that level. The wick took
// the inferred liquidity above the level and price rejected it on the same
// bar — a bearish rejection. A marker is drawn at that bar and the pool is
// consumed (its line ends at the sweep bar).
// SWEEP DOWN: the mirror image (low below an active pool-low level, close
// back above it) — a bullish rejection, marked at that bar, pool consumed.
// GENUINE BREAK: a bar that CLOSES beyond a pool level (above a pool high,
// below a pool low) removes the pool silently — no marker. Sweeps and
// breakouts are distinguished by the CLOSE, never by the wick.
// All detection uses only data up to the current bar's close; pool creation
// happens at pivot confirmation; every marker and state change is gated by
// barstate.isconfirmed, so markers never move or disappear after the bar
// that created them.
// ── Inputs ──────────────────────────────────────────────────────────────────
grpPools = "Liquidity pools"
pivotLen = input.int(5, "Pivot length (bars each side; confirmation lag)", minval = 1, maxval = 20, group = grpPools)
maxPools = input.int(10, "Maximum pools kept per side", minval = 1, maxval = 50, group = grpPools)
extendBars = input.int(50, "Extend each pool line this many bars right", minval = 1, maxval = 500, group = grpPools)
lineWidth = input.int(2, "Pool line width", minval = 1, maxval = 4, group = grpPools)
aboveColor = input.color(color.new(color.red, 0), "Pool-above (pivot high) line color", group = grpPools)
belowColor = input.color(color.new(color.teal, 0), "Pool-below (pivot low) line color", group = grpPools)
grpMarkers = "Sweep markers"
markerShape = input.string("Arrow", "Marker shape", options = ["Arrow", "Triangle"], group = grpMarkers)
markerSize = input.string("small", "Marker size", options = ["tiny", "small"], group = grpMarkers)
labelMode = input.string("Buy/Sell", "Marker text mode", options = ["Buy/Sell", "Call/Put"], group = grpMarkers)
sweepUpColor = input.color(color.new(color.red, 0), "Sweep-up marker color", group = grpMarkers)
sweepDnColor = input.color(color.new(color.teal, 0), "Sweep-down marker color", group = grpMarkers)
grpTable = "Smart table"
showTable = input.bool(true, "Show smart table", group = grpTable)
tableSize = input.string("small", "Table text size", options = ["tiny", "small", "normal"], group = grpTable)
tablePos = input.string(position.top_right, "Table position", options = [position.top_left, position.top_right, position.bottom_left, position.bottom_right], group = grpTable)
// ── Pivot detection (confirmed pivots only — no repainting) ─────────────────
ph = ta.pivothigh(high, pivotLen, pivotLen) // non-na on the confirmation bar, value = pivot high price
pl = ta.pivotlow(low, pivotLen, pivotLen) // non-na on the confirmation bar, value = pivot low price
// ── Pool storage (parallel arrays: one drawing + one level per pool) ────────
var line[] hiLines = array.new_line()
var float[] hiLvls = array.new_float()
var line[] loLines = array.new_line()
var float[] loLvls = array.new_float()
var string lastSweepTxt = "—"
var int lastSweepBar = na
var bool sweepUpBar = false
var bool sweepDnBar = false
sweepUpBar := false
sweepDnBar := false
f_trimHi() =>
while array.size(hiLines) > maxPools
line.delete(array.shift(hiLines))
array.shift(hiLvls)
f_trimLo() =>
while array.size(loLines) > maxPools
line.delete(array.shift(loLines))
array.shift(loLvls)
f_markerSize(_s) =>
_s == "tiny" ? size.tiny : size.small
// ── Sweep / break evaluation and pool creation (confirmed bars only) ────────
if barstate.isconfirmed
// Pool highs: a close ABOVE the level is a genuine break (silent
// removal); a wick above with a close back below is a sweep up.
i = array.size(hiLvls) - 1
while i >= 0
lvl = array.get(hiLvls, i)
if close > lvl
line.set_x2(array.get(hiLines, i), bar_index)
array.remove(hiLines, i)
array.remove(hiLvls, i)
else if high > lvl and close < lvl
sweepUpBar := true
line.set_x2(array.get(hiLines, i), bar_index)
array.remove(hiLines, i)
array.remove(hiLvls, i)
i -= 1
// Pool lows: mirror image.
j = array.size(loLvls) - 1
while j >= 0
lvl = array.get(loLvls, j)
if close < lvl
line.set_x2(array.get(loLines, j), bar_index)
array.remove(loLines, j)
array.remove(loLvls, j)
else if low < lvl and close > lvl
sweepDnBar := true
line.set_x2(array.get(loLines, j), bar_index)
array.remove(loLines, j)
array.remove(loLvls, j)
j -= 1
// Markers: drawn once, on the sweep bar, and never moved or deleted.
if sweepUpBar
txt = labelMode == "Buy/Sell" ? "SELL" : "PUT"
sty = markerShape == "Arrow" ? label.style_arrow_down : label.style_triangle_down
label.new(bar_index, high, txt, style = sty, color = sweepUpColor, textcolor = color.white, size = f_markerSize(markerSize))
lastSweepTxt := "Up (above pool)"
lastSweepBar := bar_index
if sweepDnBar
txt = labelMode == "Buy/Sell" ? "BUY" : "CALL"
sty = markerShape == "Arrow" ? label.style_arrow_up : label.style_triangle_up
label.new(bar_index, low, txt, style = sty, color = sweepDnColor, textcolor = color.white, size = f_markerSize(markerSize))
lastSweepTxt := "Down (below pool)"
lastSweepBar := bar_index
// New pools from pivots confirmed on this bar. The line starts at the
// pivot bar (pivotLen bars back) and extends right from this bar.
if not na(ph)
array.push(hiLines, line.new(bar_index - pivotLen, ph, bar_index + extendBars, ph, color = aboveColor, width = lineWidth))
array.push(hiLvls, ph)
f_trimHi()
if not na(pl)
array.push(loLines, line.new(bar_index - pivotLen, pl, bar_index + extendBars, pl, color = belowColor, width = lineWidth))
array.push(loLvls, pl)
f_trimLo()
// ── Smart table (all text white) ────────────────────────────────────────────
var table dash = table.new(tablePos, 2, 5, bgcolor = color.new(color.black, 25), border_width = 1, border_color = color.white)
if barstate.islast
if showTable
ago = na(lastSweepBar) ? "—" : lastSweepTxt + " · " + str.tostring(bar_index - lastSweepBar) + " bars ago"
table.cell(dash, 0, 0, "Liquidity Sweep", text_color = color.white, text_size = tableSize)
table.cell(dash, 1, 0, "", text_color = color.white, text_size = tableSize)
table.cell(dash, 0, 1, "Pools above", text_color = color.white, text_size = tableSize)
table.cell(dash, 1, 1, str.tostring(array.size(hiLvls)), text_color = color.white, text_size = tableSize)
table.cell(dash, 0, 2, "Pools below", text_color = color.white, text_size = tableSize)
table.cell(dash, 1, 2, str.tostring(array.size(loLvls)), text_color = color.white, text_size = tableSize)
table.cell(dash, 0, 3, "Last sweep", text_color = color.white, text_size = tableSize)
table.cell(dash, 1, 3, ago, text_color = color.white, text_size = tableSize)
table.cell(dash, 0, 4, "Pivot length", text_color = color.white, text_size = tableSize)
table.cell(dash, 1, 4, str.tostring(pivotLen), text_color = color.white, text_size = tableSize)
else
table.clear(dash)
// ── Alerts (descriptive only — a detected pattern, not a signal to trade) ───
alertcondition(sweepUpBar, title = "Sweep up (wick above pool high, close back below)", message = "Liquidity sweep up under the indicator's mechanical definition on {{exchange}}:{{ticker}} ({{interval}}): a bar's high exceeded a confirmed pivot-high pool level and its close was back below that level.")
alertcondition(sweepDnBar, title = "Sweep down (wick below pool low, close back above)", message = "Liquidity sweep down under the indicator's mechanical definition on {{exchange}}:{{ticker}} ({{interval}}): a bar's low exceeded a confirmed pivot-low pool level and its close was back above that level.")
Questions about this product
Is there a free Pine Script for liquidity sweeps on TradingView?
Yes. Script Master Labs publishes this Liquidity Sweep Indicator as a free Pine Script v6 download on SML Dual Market (https://dual.scriptmasterlabs.com/product/free-liquidity-sweep-indicator). The complete source is printed in full on the product page and in the free download — no payment, no account, no subscription.
How do I use the Liquidity Sweep Indicator?
Open TradingView's Pine Editor, create a new blank script, paste the source, click Save, then Add to chart. Adjust the inputs from the gear icon. TradingView's first-steps page shows where the editor opens: https://tradingview.com/pine-script-docs/primer/first-steps
Does it work on TradingView's free plan?
Yes. Paste the source into TradingView's Pine Editor and add it to your chart; the free plan runs custom indicators.
Is the free edition the complete script?
Yes — the same Pine Script v6 source file sold in the paid edition ($19 one-time). The paid edition adds the full written user guide, the evidence receipt, and the licensing and security reviews; nothing in the script itself is held back.
Does it repaint?
No. Its events are computed on confirmed bars only; a marker, once printed, does not move or disappear.