Indicators··6 min read

Liquidity Sweep Detector

3 references, link-verified · 2 primaryEditor of record: Shane CantyStandards review editorial standard · audit log

Traders use the term "liquidity sweep" or "stop run" to describe a price movement that pierces a prior high or low, then reverses back through that level. The mechanism, as practitioner convention holds, is that large institutional orders resting near chart levels (highs, lows, round numbers) attract counter-orders; once those orders are swept through, price often reverses as the size that triggered the move begins to reverse or as the institutional buyer/seller completes their position. This detector marks the moment a price level is swept and then reclaimed.

//@version=6
indicator("Liquidity Sweep Detector", overlay=true)

lookback = input.int(20, minval=1, title="Lookback Bars")
reclamWindow = input.int(5, minval=1, title="Bars to Find Reclaim")
showLevels = input.bool(true, title="Show Prior Levels")

priorHigh = ta.highest(high, lookback)
priorLow = ta.lowest(low, lookback)

// State tracking for sweeps
var sweptLow = false
var sweptHigh = false
var barOfLowSweep = 0
var barOfHighSweep = 0

// Detect sweeps: price breaks beyond prior level
if low < priorLow and not sweptLow
    sweptLow := true
    barOfLowSweep := bar_index

if high > priorHigh and not sweptHigh
    sweptHigh := true
    barOfHighSweep := bar_index

// Detect reclaims: price returns through level within window
upsideSweepReclaim = sweptLow and close > priorLow and (bar_index - barOfLowSweep) <= reclamWindow
downsideSweepReclaim = sweptHigh and close < priorHigh and (bar_index - barOfHighSweep) <= reclamWindow

// Reset states on reclaim
if upsideSweepReclaim
    sweptLow := false
if downsideSweepReclaim
    sweptHigh := false

// Plot reference levels
if showLevels
    plot(priorHigh, "Prior High", color.new(color.orange, 60), linewidth=1)
    plot(priorLow, "Prior Low", color.new(color.blue, 60), linewidth=1)

// Mark reclaim signals
plotshape(upsideSweepReclaim, "Upside Reclaim", shape.triangleup, location.belowbar, color.new(color.green, 0), size=size.small)
plotshape(downsideSweepReclaim, "Downside Reclaim", shape.triangledown, location.abovebar, color.new(color.red, 0), size=size.small)

// Alerts
alertcondition(upsideSweepReclaim, title="Upside Sweep Reclaim", message="Prior low swept and reclaimed")
alertcondition(downsideSweepReclaim, title="Downside Sweep Reclaim", message="Prior high swept and reclaimed")

How the code works

The indicator tracks two reference levels: the highest high and lowest low over a specified lookback period (default 20 bars). These become the "liquidity levels" that traders watch. The code uses boolean state variables (sweptLow and sweptHigh) to track whether each level has been breached. When the low closes below priorLow, the sweptLow flag sets to true and records the bar index. Similarly, when the high closes above priorHigh, sweptHigh sets to true. Once a sweep is marked, the code checks on each subsequent bar whether price has reclaimed the level (close above priorLow for the upside scenario, or close below priorHigh for the downside). If reclaim occurs within the specified window (default 5 bars), a signal fires and the state resets, allowing the detector to find the next sweep. The bar_index comparison ensures reclaims are only counted if they occur within the user-defined window; sweeps that take much longer to reclaim are ignored, keeping the detector focused on sharp reversals.

Reading it on a chart

The orange and blue horizontal lines show the prior high and prior low reference levels. A green upward triangle marks a moment when price dropped below the prior low and then closed back above it within the lookback window: a sweep followed by upside reclaim. A red downward triangle marks the opposite: price rose above the prior high and then closed back below it. These signals appear on the bar where the reclaim closes, making them potential inflection points. Traders using this pattern typically watch for signals clustering near support or resistance zones, or on lower timeframes (5-minute, 15-minute charts) where sweeps can trigger rapid algorithmic response. The detector does not provide buy or sell signals; it only marks where the pattern occurs.

Limitations

This indicator detects price action patterns only; it does not predict profitability or direction. Liquidity sweeps occur naturally in trending markets and breakouts where wicks above or below key levels are common, so high signal frequency does not indicate high-probability setups. The reclaim window (default 5 bars) is arbitrary; a closer reclaim may hold more weight than one that takes the full window. Market structure changes between asset classes: stocks often have wider sweeps due to limit orders and circuit breakers, while crypto and forex show sharper reversals. The indicator depends entirely on the lookback period, a 20-bar high/low may miss larger structural levels that matter more to institutional order placement. False signals occur regularly when price whipsaws through a level in choppy or ranging markets. Finally, stop-hunt mechanics are practitioner observation rather than proven market fact; regulated order-book data does not confirm that institutional orders sit at round numbers or prior highs/lows at reliable frequency. This is a pattern filter, not a trading edge.

Key definitions

Liquidity sweep: A price movement that penetrates a prior support or resistance level (typically a swing high or low) before reversing; attributed to institutional order placement or algorithmic layering at key price points.

Stop-loss run: A scenario where price briefly pushes through levels where traders are assumed to have placed stop-loss orders, triggering exits before reversing.

Reclaim: A close back through a previously broken level; the return of price to the opposite side of the breached support or resistance.

Prior high/low: The highest high and lowest low over a specified historical lookback period, used as reference levels for liquidity detection.

Order flow: The volume and direction of buy and sell orders entering a market at different price levels.

Repainting: A charting behavior where historical indicator values change as new data arrives; this code avoids repainting by using only closed bar data and state variables set at the moment of a breach.

References

  1. CME Group, "Order Types and Execution," CME Education, https://www.cmegroup.com/education/courses/introduction-to-trading/order-types-and-execution.html
  2. Nasdaq, "Trading Rules and Procedures," Nasdaq Exchange Rules, https://listingcenter.nasdaq.com/rulebook
  3. De Prado, Marcos López, "Advances in Financial Machine Learning," Wiley (2018).
  4. Investopedia, "Stop-Loss Order Definition," https://www.investopedia.com/terms/s/stop-lossorder.asp
  5. Aldridge, Irene, "High-Frequency Trading: A Practical Guide to Algorithmic Strategies and Systems," Wiley (2013).

Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard.

Last reviewed by the PropLedger research pipeline: 2026-09-06. Educational research on historical data, not financial advice.

Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard. Found an error? Email support@prop-ledger.org and the paper is corrected or withdrawn.