Strategy Concept
Financial markets often move toward areas where stop orders accumulate. These areas are usually located above recent highs or below recent lows.
When price briefly breaks those levels and quickly returns back inside the range, it can signal that liquidity has been taken and the market may move in the opposite direction.
This strategy focuses on detecting those situations. Instead of chasing breakouts, it waits for price to sweep liquidity and then confirm a shift in market structure before opening a trade.
How the Strategy Works
Liquidity Sweep Detection
The script first identifies recent swing highs and swing lows.
A sweep happens when:
- Price moves above a recent high but closes back below it
- Price moves below a recent low but closes back above it This behavior suggests that stop orders were triggered but the breakout did not continue.
Market Structure Confirmation
After a sweep occurs, the strategy waits for confirmation from market structure.
- For a long setup, price must break above a recent short-term high after sweeping liquidity below.
- For a short setup, price must break below a recent short-term low after sweeping liquidity above.
This helps reduce random entries.
Volatility-Based Risk Control
The script uses ATR (Average True Range) to calculate stop-loss and take-profit levels.
This allows the strategy to adapt to changing market conditions. When volatility expands, exits widen; when volatility contracts, exits become tighter.
Key Characteristics
- Detects stop-run style moves
- Confirms entries using structure shifts
- Uses volatility-adaptive exits
- Designed for testing and educational purposes
Where This Strategy May Perform Better
This type of setup often appears during:
- active trading sessions
- volatile market phases
- instruments with strong liquidity
Sideways markets with very low volatility may produce fewer reliable signals.
//@version=6
strategy("Liquidity Sweep + Market Structure Strategy",
overlay=true,
initial_capital=100000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=5)
// Inputs
lookback = input.int(20, "Liquidity Lookback")
structureLen = input.int(5, "Structure Length")
atrLen = input.int(14, "ATR Length")
atrMult = input.float(1.5, "Stop ATR Multiplier")
rr = input.float(2.0, "Risk Reward")
// Liquidity levels
recentHigh = ta.highest(high[1], lookback)
recentLow = ta.lowest(low[1], lookback)
// Sweep detection
sweepHigh = high > recentHigh and close < recentHigh
sweepLow = low < recentLow and close > recentLow
// Market structure levels
structureHigh = ta.highest(high, structureLen)
structureLow = ta.lowest(low, structureLen)
// Structure break
bullStructureBreak = close > structureHigh[1]
bearStructureBreak = close < structureLow[1]
// Entry logic
longCondition = sweepLow[1] and bullStructureBreak
shortCondition = sweepHigh[1] and bearStructureBreak
// ATR risk control
atrValue = ta.atr(atrLen)
if longCondition and strategy.position_size == 0
strategy.entry("Long", strategy.long)
if shortCondition and strategy.position_size == 0
strategy.entry("Short", strategy.short)
// Exit levels
longStop = strategy.position_avg_price - atrValue * atrMult
longTake = strategy.position_avg_price + atrValue * atrMult * rr
shortStop = strategy.position_avg_price + atrValue * atrMult
shortTake = strategy.position_avg_price - atrValue * atrMult * rr
strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longTake)
strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortTake)
// Visuals
plot(recentHigh, title="Liquidity High", color=color.red)
plot(recentLow, title="Liquidity Low", color=color.green)
Top comments (0)