Liquidity Sweep Detector [QuantAlgo]🟢 Overview
The Liquidity Sweep Detector is a swing-based liquidity tracking tool that identifies moments when price wicks beyond a confirmed swing high or low and closes back inside, then tracks the remaining unswept levels as forward-projecting lines and zones on your chart. It classifies each event by direction (Bullish or Bearish) and maintains a running registry of swing levels that have not yet been visited by price, giving you a live map of where resting stop clusters may still be sitting across any timeframe and market.
🟢 How It Works
The indicator identifies swing highs and lows using a pivot detection window that requires a configurable number of bars to the left and right to confirm a valid structural point. The active pivot length and minimum wick penetration are resolved from the selected preset before any detection runs:
active_len = preset_config == 'Scalp' ? 5 : preset_config == 'Swing' ? 20 : pivot_len
active_min_pct = preset_config == 'Scalp' ? 0.0 : preset_config == 'Swing' ? 0.05 : min_wick_pct
A bearish sweep is confirmed when price wicks above the most recent swing high by at least the minimum penetration percentage and closes back below it. A bullish sweep mirrors this on the downside:
bearSweep = not na(lastSwingHigh) and high > lastSwingHigh * (1 + active_min_pct / 100) and close < lastSwingHigh
bullSweep = not na(lastSwingLow) and low < lastSwingLow * (1 - active_min_pct / 100) and close > lastSwingLow
Every confirmed swing point is simultaneously stored in an unswept level registry. Levels are removed when the full candle closes beyond them, or immediately when a sweep is confirmed on that level, so the chart only shows levels price has not yet visited:
if bearSweep and array.size(unsweptHighs) > 0
for i = array.size(unsweptHighs) - 1 to 0
if array.get(unsweptHighs, i) == lastSwingHigh
array.remove(unsweptHighs, i)
array.remove(unsweptHighBars, i)
break
The indicator also detects when price enters the zone around an unswept level without yet confirming a full sweep. Edge detection ensures the alert fires once on entry rather than on every bar price remains inside the zone:
buySideEntry = enteredBuySide and not enteredBuySide
sellSideEntry = enteredSellSide and not enteredSellSide
🟢 Key Features
▶ Three Preset Configurations: The indicator includes three presets that override the manual pivot length and minimum wick penetration settings.
1. Default/Custom: A general-purpose configuration suited to swing trading on 4H and daily charts. Confirms swing points that require a reasonable structural context before a sweep is flagged.
2. Scalp: A faster configuration for intraday charts from 1 minute to 15 minutes. Shorter pivot windows capture local swing points that form and get swept within a single session.
3. Swing: A more conservative configuration for daily and weekly charts that requires a more deliberate wick extension before confirming a sweep, filtering out shallow tags at swing levels.
▶ Built-in Alert System: Pre-configured alert conditions cover bearish sweeps, bullish sweeps, any sweep, price entering a buy-side zone, price entering a sell-side zone, and price entering any unswept zone.
▶ Visual Customisation: Choose from five colour presets (Classic, Aqua, Cosmic, Cyber, Neon) or set your own custom colours. Optional candle background highlighting marks sweep bars directly on the chart, and label text size is configurable across four options to suit different chart layouts.
🟢 Important Considerations
▶ Sweep detection references only the most recently confirmed swing high or low at the time each bar closes. On lower timeframes with frequent swing formation, raising the pivot length focuses detection on more structurally significant levels and reduces signal frequency on choppy charts.
▶ The indicator works best as a contextual layer within an existing trading framework. Sweep signals indicate that price has moved beyond a swing level and closed back inside, which is a useful data point, but should be read alongside your system and market context rather than used as a standalone trigger.
Indicateur Pine Script®






















