Liquidity Sweep Detector
A liquidity sweep occurs when price breaks a significant prior high or low, then immediately reclaims back past that level within the same bar. Traders watch for sweeps because they often precede sharp moves in the opposite direction: stops are triggered on the initial break, then removed liquidity pulls the market back. This indicator marks bars where price swept a prior level and closed back inside it, signaling potential institutional participation.
//@version=6
indicator("Liquidity Sweep Detector", overlay=true, max_labels=500)
// Inputs
lookback = input.int(20, title="Lookback Period (bars)", minval=5, maxval=100)
showHighSweep = input.bool(true, title="Detect High Sweeps")
showLowSweep = input.bool(true, title="Detect Low Sweeps")
showLevels = input.bool(true, title="Show Level Lines")
colorBull = input.color(color.new(color.green, 30), title="Bullish (Low Sweep) Color")
colorBear = input.color(color.new(color.red, 30), title="Bearish (High Sweep) Color")
// Calculate highest high and lowest low from lookback period
priorHigh = ta.highest(high, lookback)
priorLow = ta.lowest(low, lookback)
// Detect sweep + reclaim in a single bar
// High sweep: price rallies above prior high, then closes back below
highSweepReclaim = high > priorHigh and close < priorHigh
// Low sweep: price drops below prior low, then closes back above
lowSweepReclaim = low < priorLow and close > priorLow
// Plot prior levels
if showLevels
plot(priorHigh, color=color.new(color.orange, 60), linewidth=1, title="Prior High")
plot(priorLow, color=color.new(color.orange, 60), linewidth=1, title="Prior Low")
// Mark occurrences
if showHighSweep and highSweepReclaim
label.new(bar_index, high, "H-Sweep", style=label.style_diamond,
color=colorBear, textcolor=color.white, size=size.small)
if showLowSweep and lowSweepReclaim
label.new(bar_index, low, "L-Sweep", style=label.style_diamond,
color=colorBull, textcolor=color.white, size=size.small)
How the code works
The indicator establishes reference levels by finding the highest high and lowest low across a user-defined lookback period (default 20 bars). These are plotted as horizontal lines to visualize the prior structure.
On each new bar, the code evaluates two conditions for a high sweep: the bar's high must exceed the prior high (the swing point is broken), and the close must fall back below that same prior high. This creates the characteristic "wick above and rejection" pattern. Conversely, a low sweep requires the low to dip below the prior low while the close recovers above it.
The ta.highest() and ta.lowest() functions automatically recalculate the prior levels as new bars form, ensuring they always represent the structure relative to the current position on the chart. Labels are placed only when both conditions are met within a single bar, eliminating false signals from bars that merely touch without reclaiming.
Reading it on a chart
When an "H-Sweep" label appears, price has just spiked above a recent swing high and closed back underneath it. This typically signals that aggressive buy-side liquidity pushed the market higher to trigger stop-losses, then selling pressure reasserted control. Many practitioners treat this as a bearish continuation setup, expecting downside to follow.
Conversely, an "L-Sweep" label marks a dip below a swing low that was immediately reclaimed and closed above. This pattern suggests stops below the level were absorbed and the bid protected the level; upside continuation often follows.
The orange level lines themselves serve as visual reference: they update continuously as new highs and lows form, so the "prior high" yesterday may shift today if a new swing point is established. Traders often use these levels as support/resistance zones independent of the sweep signal.
Use the Lookback Period input to tune the indicator for the timeframe and trading style: shorter lookbacks (5-10 bars) detect tighter, more frequent sweeps on intraday charts; longer lookbacks (40-50 bars) filter to only the most significant structural levels on daily or weekly charts.
Limitations
This indicator identifies the pattern of a sweep and reclaim within a single bar; it does not predict the subsequent move. Not all sweeps lead to the expected directional continuation. Volume, volatility regimes, and broader market structure all influence whether a sweep marks institutional manipulation or simply a normal wick. On illiquid instruments or during low-volatility periods, wick-driven sweeps may be noise rather than signal.
The indicator repaint risk is minimal because it locks in labels at the close of the bar, but the priorHigh and priorLow lines do shift slightly each bar as the lookback window rolls forward. Traders should not rely on these levels as rigid support/resistance; they are approximate guides only.
The single-bar sweep detection misses multi-bar patterns where the sweep and reclaim span more than one candle. Some market microstructure sweeps take two or three bars to complete. To capture those, manually extend the scan logic or overlay this indicator with price action analysis.
Finally, the indicator works best on liquid, continuous markets where OHLC data is reliable and slippage on spike levels is minimal. On gapped or thinly traded instruments, the high/low may not reflect true liquidity sweep mechanics.
Key definitions
Liquidity sweep: A price move through a technical level (prior high or low) that triggers stop-losses, followed by a reversal that closes the bar back inside the level, suggesting institutional or algorithmic participation in the move.
Prior high/low: The highest high or lowest low within the specified lookback period; used as a reference level to identify structural support and resistance.
Reclaim: Price's return past a broken level in the opposite direction, typically signaling rejection of the initial directional push and renewed control by the opposite side.
Stop-loss absorption: The act of triggering sell-side stops above a level or buy-side stops below a level, often followed by removal of those orders as institutions exit counter-positions.
Swing point: A local high or low on a price chart; used as a reference level for technical analysis and stop placement.
Wick: The portion of a candlestick that extends beyond the open-close range, representing price movement beyond where the bar ultimately closed.
References
-
CME Group, "Equity Index Futures Contract Specifications", CME Education. Https://www.cmegroup.com/markets/equities/equity-index.html
-
ICE Futures, "Market Surveillance and Manipulation Prevention", ICE Rulebook. Https://www.theice.com/
-
SEC Division of Trading and Markets, "Market Manipulation and Disruptive Devices", 17 CFR 240. https://www.sec.gov/cgi-bin/browse-edgar
-
Investopedia, "Support and Resistance", Financial Education. Https://www.investopedia.com/terms/s/support.asp
-
Wyckoff, Richard D., "Studies in Tape Reading", Fraser Publishing Company (1910). Foundational text on price action interpretation and institutional order flow detection.
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-20. Educational research on historical data, not financial advice.
Keep reading
Prior Day High, Low, and Settlement
Free open-source Pine Script indicator: prior day high, low, and settlement levels. Full code and a plain-English walkthrough.
Seasonality Heat Strip: Month-of-Year Average Returns
Free open-source Pine Script indicator: seasonality heat strip: month-of-year average returns. Full code and a plain-English walkthrough.
Spread Tracker: Futures Pair
Free open-source Pine Script indicator: spread tracker between two related futures contracts. Full code and a plain-English walkthrough.