Indicator · Pine Script v5 · On the chart

Liquidity Sweeps [UAlgo]

by alvinng214· code credited to UAlgo

Calculates pivot highs and pivot lows over a customizable length to draw horizontal support and resistance lines on the price chart.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code70
Settings5inputs
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

70 lines of Pine Script v5 from S1_Silver_Bullet/Liquidity Sweeps [UAlgo].txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Liquidity Sweeps [UAlgo].txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © UAlgo

//@version=5
indicator("Liquidity Sweeps [UAlgo]", overlay = true, max_lines_count = 500)

pivotPeriod    = input.int(20, "Pivot Length", 3, 100, 1, "", "", "Pivot Left Right Length",tooltip = "Left - Right Length")
maxLine   = input.int(3, "Maximum Lines", 1, 100, 1, "Maximum S/R lines to draw", "", "S/R Settings")
resistanceColor    = input.color(color.rgb(255, 82, 82, 53), "S & R", "", "colors", "Color")
supportColor    = input.color(color.rgb(76, 175, 79, 32), "", "", "colors", "Color")
lineWidth = input.int(2, "", 0, 5, 1, "Resistance Line Colors\n\nSupport Line Colors\n\nLine Width", "colors", "Color")

pivotHigh = ta.pivothigh(high,pivotPeriod, pivotPeriod)
pivotLow  = ta.pivotlow(low,pivotPeriod, pivotPeriod)

atrOffset=ta.atr(14)

var resistanceArray = array.new_line()
var supportArray = array.new_line()

ph = not na(pivotHigh)
pl = not na(pivotLow)

if ph
    drawNewHigh = line.new(bar_index[pivotPeriod], high[pivotPeriod], bar_index, high[pivotPeriod], color = resistanceColor, width = lineWidth)
    array.push(resistanceArray, drawNewHigh)

    if array.size(resistanceArray) > maxLine
        line.delete(array.get(resistanceArray, 0))
        array.remove(resistanceArray, 0)

for i = array.size(resistanceArray) - 1 to 0 
    if array.size(resistanceArray)  > 0
        line.set_x2(array.get(resistanceArray, i), bar_index)
        highPrice = line.get_y1(array.get(resistanceArray, i))
        priceHighLoc = line.get_x1(array.get(resistanceArray, i))

        if ((high > highPrice) and (close < highPrice)) 
            line.delete(array.get(resistanceArray, i))
            line.new(priceHighLoc, highPrice, bar_index, high, color = color.purple, width = 1)
            array.remove(resistanceArray, i)
            label.new(bar_index, highPrice+atrOffset, "Buy Liquidity Sweep", style=label.style_label_down,textcolor = color.white,size = size.small, color =color.purple)
        else if (close > highPrice)
            line.delete(array.get(resistanceArray, i))
            array.remove(resistanceArray, i)

if pl
    drawNewLow = line.new(bar_index[pivotPeriod], low[pivotPeriod], bar_index, low[pivotPeriod], color = supportColor, width = lineWidth)
    array.push(supportArray, drawNewLow)

    if array.size(supportArray) > maxLine
        line.delete(array.get(supportArray, 0))
        array.remove(supportArray, 0)

for i = array.size(supportArray) - 1 to 0

    if array.size(supportArray)  > 0
        line.set_x2(array.get(supportArray, i), bar_index)
        lowPrice = line.get_y1(array.get(supportArray, i))
        priceLoc = line.get_x1(array.get(supportArray, i))

        if (low < lowPrice and close > lowPrice) 
            line.delete(array.get(supportArray, i))
            array.remove(supportArray, i)
            line.new(priceLoc, lowPrice, bar_index, low, color = color.blue, width = 1)
            label.new(bar_index, lowPrice-atrOffset, "Sell Liquidity Sweep", style=label.style_label_up,textcolor = color.white,size = size.small)

        else if (close < lowPrice)
            line.delete(array.get(supportArray, i))
            array.remove(supportArray, i)

Overview

When price spikes past a pivot level but closes back within the range, the indicator identifies a buy or sell liquidity sweep, places a label offset by ATR, and removes the swept level. Key settings allow adjustment of the pivot lookback period, maximum displayed lines, and line aesthetics.

Details

Published by

alvinng214 on GitHub

Code credit

UAlgo, as written in the script's header

Type

Indicator, Pine Script v5

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
Pivot Lengthint20pivotPeriod
Maximum Linesint3maxLine
S & Rcolorcolor.rgb(255, 82, 82, 53)resistanceColor
supportColorcolorcolor.rgb(76, 175, 79, 32)supportColor
lineWidthint2lineWidth
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