Indicator · Pine Script v6 · On the chart

Liquidity Hunter | AlphaScript

by alvinng214· code credited to AlphaScript

The Liquidity Sweep Hunter indicator identifies liquidity sweeps on swing highs and lows.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code292
Settings13inputs
LicenceNone statedfile: MPL-2.0
Last update2 months ago5 Aug 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

292 lines of Pine Script v6 from S1_Silver_Bullet/Liquidity Sweep Hunter | AlphaScript.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Liquidity Sweep Hunter | AlphaScript.txt
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlphaScript

//@version=6
indicator("Liquidity Sweep Hunter | AlphaScript", shorttitle="Liquidity Hunter | AlphaScript", overlay=true, max_lines_count=200, max_labels_count=100)

// ============================================================
// INPUTS
// ============================================================
grpSwing   = "Swing Detection"
grpFilter  = "Filters"
grpDisplay = "Display"
grpAlerts  = "Alerts"

swingLen    = input.int(10,    title="Swing Lookback",        minval=3,  maxval=50, group=grpSwing)
sweepMode   = input.string("Both", title="Sweep Mode",       options=["Wick", "Retest", "Both"], group=grpSwing)
maxLevels   = input.int(10,    title="Max Active Levels",     minval=5,  maxval=100, group=grpSwing)
maxAge      = input.int(300,   title="Max Level Age (bars)",  minval=50, maxval=2000, group=grpSwing)
maxSweeps   = input.int(10,    title="Max Visible Sweeps",    minval=1,  maxval=50, group=grpSwing)
recentBars  = input.int(500,   title="Show Signals (recent bars)", minval=50, maxval=5000, group=grpSwing, tooltip="Plotshape triangles only appear on the most recent N bars to reduce chart noise.")

atrLen      = input.int(14,    title="ATR Length",            minval=5,  group=grpFilter)
atrMult     = input.float(0.1, title="Min Wick ATR Mult",     minval=0.0, maxval=2.0, step=0.05, group=grpFilter, tooltip="Minimum wick size beyond level as multiple of ATR. 0 = no filter.")

showLines   = input.bool(true,  title="Show Level Lines",     group=grpDisplay)
showLabels  = input.bool(true,  title="Show Sweep Labels",    group=grpDisplay)
bullCol     = input.color(#00bcd4, title="Bullish Sweep Color", group=grpDisplay)
bearCol     = input.color(#f23645, title="Bearish Sweep Color", group=grpDisplay)
levelCol    = input.color(#787b86, title="Level Line Color",    group=grpDisplay)

// ============================================================
// HELPERS
// ============================================================
atrVal = ta.atr(atrLen)

inRecentWindow = bar_index >= last_bar_index - recentBars

// ============================================================
// STATE — UDT for swing levels
// ============================================================
type SwingLevel
    float  price
    int    lvlTime
    int    lvlBar
    bool   isBull
    bool   broken
    line   lvlLine

var SwingLevel[] bullLevels = array.new<SwingLevel>()
var SwingLevel[] bearLevels = array.new<SwingLevel>()

var line[]  sweepLines  = array.new<line>()
var label[] sweepLabels = array.new<label>()

var line[] bullLevelLines = array.new<line>()
var line[] bearLevelLines = array.new<line>()

// ============================================================
// PIVOT DETECTION (confirmed bars only — repaint-safe)
// ============================================================
ph = ta.pivothigh(high, swingLen, swingLen)
pl = ta.pivotlow(low,  swingLen, swingLen)

if not na(ph) and barstate.isconfirmed
    if showLines and bearLevelLines.size() >= maxLevels
        old = bearLevelLines.shift()
        line.delete(old)
    newLine = showLines ? line.new(
         x1    = time[swingLen],
         y1    = ph,
         x2    = time,
         y2    = ph,
         xloc  = xloc.bar_time,
         extend = extend.right,
         color  = color.new(levelCol, 40),
         style  = line.style_dotted,
         width  = 1) : line(na)
    if showLines
        bearLevelLines.push(newLine)
    lvl = SwingLevel.new(
         price   = ph,
         lvlTime = time[swingLen],
         lvlBar  = bar_index - swingLen,
         isBull  = false,
         broken  = false,
         lvlLine = newLine
    )
    bearLevels.push(lvl)
    if bearLevels.size() > maxLevels
        old = bearLevels.shift()
        line.delete(old.lvlLine)

if not na(pl) and barstate.isconfirmed
    if showLines and bullLevelLines.size() >= maxLevels
        old = bullLevelLines.shift()
        line.delete(old)
    newLine = showLines ? line.new(
         x1    = time[swingLen],
         y1    = pl,
         x2    = time,
         y2    = pl,
         xloc  = xloc.bar_time,
         extend = extend.right,
         color  = color.new(levelCol, 40),
         style  = line.style_dotted,
         width  = 1) : line(na)
    if showLines
        bullLevelLines.push(newLine)
    lvl = SwingLevel.new(
         price   = pl,
         lvlTime = time[swingLen],
         lvlBar  = bar_index - swingLen,
         isBull  = true,
         broken  = false,
         lvlLine = newLine
    )
    bullLevels.push(lvl)
    if bullLevels.size() > maxLevels
        old = bullLevels.shift()
        line.delete(old.lvlLine)

// ============================================================
// SWEEP DETECTION — runs on confirmed bars only
// ============================================================
bullSweep = false
bearSweep = false
bullSweepPrice = 0.0
bearSweepPrice = 0.0

f_capSweepDrawings() =>
    if sweepLabels.size() > maxSweeps
        old = sweepLabels.shift()
        label.delete(old)
    if sweepLines.size() > maxSweeps
        old = sweepLines.shift()
        line.delete(old)

if barstate.isconfirmed
    // --- BEARISH SWEEP: price hunts a swing HIGH (Buy Side Liquidity taken) ---
    if bearLevels.size() > 0
        for i = bearLevels.size() - 1 to 0
            if i < bearLevels.size()
                lvl = bearLevels.get(i)
                age = bar_index - lvl.lvlBar
                if age > maxAge
                    line.delete(lvl.lvlLine)
                    for j = bearLevelLines.size() - 1 to 0
                        if j < bearLevelLines.size()
                            if bearLevelLines.get(j) == lvl.lvlLine
                                _ = bearLevelLines.remove(j)
                    _ = bearLevels.remove(i)
                else
                    wickBeyond = high - lvl.price
                    wickOk     = atrMult == 0.0 or wickBeyond >= atrVal * atrMult
                    swept      = false
                    if (sweepMode == "Wick" or sweepMode == "Both")
                        if high > lvl.price and close < lvl.price and wickOk
                            swept := true
                    if (sweepMode == "Retest" or sweepMode == "Both")
                        if not lvl.broken and close > lvl.price
                            lvl.broken := true
                        else if lvl.broken and close < lvl.price
                            swept := true
                    if swept
                        bearSweep      := true
                        bearSweepPrice := lvl.price
                        line.set_extend(lvl.lvlLine, extend.none)
                        line.set_x2(lvl.lvlLine, time)
                        line.set_color(lvl.lvlLine, color.new(bearCol, 20))
                        line.set_style(lvl.lvlLine, line.style_dashed)
                        line.set_width(lvl.lvlLine, 2)
                        for j = bearLevelLines.size() - 1 to 0
                            if j < bearLevelLines.size()
                                if bearLevelLines.get(j) == lvl.lvlLine
                                    _ = bearLevelLines.remove(j)
                        sweepLines.push(lvl.lvlLine)
                        _ = bearLevels.remove(i)

    // --- BULLISH SWEEP: price hunts a swing LOW (Sell Side Liquidity taken) ---
    if bullLevels.size() > 0
        for i = bullLevels.size() - 1 to 0
            if i < bullLevels.size()
                lvl = bullLevels.get(i)
                age = bar_index - lvl.lvlBar
                if age > maxAge
                    line.delete(lvl.lvlLine)
                    for j = bullLevelLines.size() - 1 to 0
                        if j < bullLevelLines.size()
                            if bullLevelLines.get(j) == lvl.lvlLine
                                _ = bullLevelLines.remove(j)
                    _ = bullLevels.remove(i)
                else
                    wickBeyond = lvl.price - low
                    wickOk     = atrMult == 0.0 or wickBeyond >= atrVal * atrMult
                    swept      = false
                    if (sweepMode == "Wick" or sweepMode == "Both")
                        if low < lvl.price and close > lvl.price and wickOk
                            swept := true
                    if (sweepMode == "Retest" or sweepMode == "Both")
                        if not lvl.broken and close < lvl.price
                            lvl.broken := true
                        else if lvl.broken and close > lvl.price
                            swept := true
                    if swept
                        bullSweep      := true
                        bullSweepPrice := lvl.price
                        line.set_extend(lvl.lvlLine, extend.none)
                        line.set_x2(lvl.lvlLine, time)
                        line.set_color(lvl.lvlLine, color.new(bullCol, 20))
                        line.set_style(lvl.lvlLine, line.style_dashed)
                        line.set_width(lvl.lvlLine, 2)
                        for j = bullLevelLines.size() - 1 to 0
                            if j < bullLevelLines.size()
                                if bullLevelLines.get(j) == lvl.lvlLine
                                    _ = bullLevelLines.remove(j)
                        sweepLines.push(lvl.lvlLine)
                        _ = bullLevels.remove(i)

// ============================================================
// LABELS — BSL for Buy Side Liquidity taken, SSL for Sell Side
// ============================================================
// [MODIFIED] bearSweep = swing HIGH taken = Buy Side Liquidity (BSL)
if bearSweep and showLabels
    lbl = label.new(
         x         = bar_index,
         y         = high,
         text      = "BSL",
         xloc      = xloc.bar_index,
         yloc      = yloc.abovebar,
         color     = color.new(bearCol, 10),
         textcolor = color.white,
         style     = label.style_label_down,
         size      = size.small)
    sweepLabels.push(lbl)
    f_capSweepDrawings()

// [MODIFIED] bullSweep = swing LOW taken = Sell Side Liquidity (SSL)
if bullSweep and showLabels
    lbl = label.new(
         x         = bar_index,
         y         = low,
         text      = "SSL",
         xloc      = xloc.bar_index,
         yloc      = yloc.belowbar,
         color     = color.new(bullCol, 10),
         textcolor = color.white,
         style     = label.style_label_up,
         size      = size.small)
    sweepLabels.push(lbl)
    f_capSweepDrawings()

// ============================================================
// PLOTSHAPE — repaint-safe signals, recent bars only
// ============================================================
plotshape(bullSweep and inRecentWindow, title="SSL — Sell Side Liquidity Taken",
     style    = shape.triangleup,
     location = location.belowbar,
     color    = bullCol,
     size     = size.small,
     text     = "")

plotshape(bearSweep and inRecentWindow, title="BSL — Buy Side Liquidity Taken",
     style    = shape.triangledown,
     location = location.abovebar,
     color    = bearCol,
     size     = size.small,
     text     = "")

// ============================================================
// DASHBOARD TABLE
// ============================================================
var table dash = table.new(position.top_right, 2, 4,
     bgcolor      = color.new(#1e222d, 5),
     border_color = color.new(#363a45, 0),
     border_width = 1)

if barstate.islast
    
    table.cell(dash, 1, 0, syminfo.ticker,   text_color=#ffeb3b, text_size=size.small, bgcolor=color.new(#2a2e39, 0))
    table.cell(dash, 0, 1, "Bull Levels",   text_color=#ffffff, text_size=size.tiny)
    table.cell(dash, 1, 1, str.tostring(bullLevels.size()), text_color=bullCol, text_size=size.tiny)
    table.cell(dash, 0, 2, "Bear Levels",   text_color=#ffffff, text_size=size.tiny)
    table.cell(dash, 1, 2, str.tostring(bearLevels.size()), text_color=bearCol, text_size=size.tiny)
    table.cell(dash, 0, 3, "Mode",          text_color=#ffffff, text_size=size.tiny)
    table.cell(dash, 1, 3, sweepMode,        text_color=#d1d4dc, text_size=size.tiny)

// ============================================================
// ALERTS
// ============================================================
alertcondition(bullSweep, title="SSL — Sell Side Liquidity Taken", message="Sell Side Liquidity swept — swing low taken, price reversed up")
alertcondition(bearSweep, title="BSL — Buy Side Liquidity Taken", message="Buy Side Liquidity swept — swing high taken, price reversed down")
alertcondition(bullSweep or bearSweep, title="Any Liquidity Sweep", message="Liquidity sweep detected")

Overview

Liquidity Hunter | AlphaScript detects wick breaks or retests that sweep through swing levels using ATR-based wick filtering. Bullish and bearish sweeps are labeled and colored on the chart. Active swing levels are displayed as dotted lines. The script supports both wick and retest sweep modes with configurable maximum levels, age, and visible sweeps.

Details

Published by

alvinng214 on GitHub

Code credit

AlphaScript, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Support & resistance, 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
Swing Lookbackint10swingLen
Sweep ModestringBothsweepMode
Max Active Levelsint10maxLevels
Max Level Age (bars)int300maxAge
Max Visible Sweepsint10maxSweeps
Show Signals (recent bars)int500recentBars
ATR Lengthint14atrLen
Min Wick ATR Multfloat0.1atrMult
Show Level LinesbooltrueshowLines
Show Sweep LabelsbooltrueshowLabels
Bullish Sweep Colorcolor#00bcd4bullCol
Bearish Sweep Colorcolor#f23645bearCol
Show all 13 settings
SettingTypeDefaultVariable
Level Line Colorcolor#787b86levelCol
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

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

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

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows

DE-tracker

by Allen1212
303 stars

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

Indicator v4 Support & resistanceSMC / ICT / price action
Updated 2 years ago · None stated GitHub repository of DE-tracker

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

Indicator v4 TrendSupport & resistance

Golden Bullet Strategy

by TradersPost
218 stars

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

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

Open Source Fractal

by cantolab
183 stars

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

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MIT GitHub repository of Open Source Fractal

Swing Failure Signals

by Ganador1
154 stars

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

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · Apache-2.0 GitHub repository of Swing Failure Signals

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