PROTECTED SOURCE SCRIPT
Liquidity Sweeper

Strategy Overview
This Pine Script implements a Liquidity Sweep Trading Strategy, a sophisticated approach that capitalizes on market manipulation tactics commonly used by institutional traders. The strategy identifies when price "sweeps" above recent swing highs or below swing lows to trigger stop losses and grab liquidity, then quickly reverses direction - creating high-probability trading opportunities.
Core Concept: What is a Liquidity Sweep?
A liquidity sweep occurs when:
Price breaks above a swing high (or below a swing low) to trigger retail stop losses
Institutional players absorb this liquidity at favorable prices
Price quickly reverses back into the previous range
This creates a "fake breakout" or "stop hunt" pattern
The strategy exploits these manipulative moves by entering trades in the direction of the reversal.
How the Strategy Works
1. Swing Point Detection
Uses a lookback period (default: 20 bars) to identify significant swing highs and lows
Employs proper pivot point detection using ta.highestbars() and ta.lowestbars()
Only considers confirmed swing points (not just recent highs/lows)
2. Liquidity Sweep Identification
High Sweep (Short Setup):
Price moves above the last swing high (triggering buy stops)
Same bar closes back below the swing high (showing rejection)
Low Sweep (Long Setup):
Price moves below the last swing low (triggering sell stops)
Same bar closes back above the swing low (showing support)
3. Confirmation Process
Requires price to stay within the swept range for a specified number of bars (default: 3)
This confirms the sweep was genuine and not just normal volatility
Prevents false signals and improves trade quality
4. Entry Logic
Long Entries: Triggered after confirmed low sweeps
Short Entries: Triggered after confirmed high sweeps
5. Risk Management
Stop Loss: Placed at a multiple of ATR (default: 1.5x) from entry price
Take Profit: Risk/Reward ratio based (default: 2:1)
Position Sizing: 10% of equity per trade (configurable)
Red X-crosses: High sweeps detected
Green X-crosses: Low sweeps detected
Red triangles (down): Short entry signals
Green triangles (up): Long entry signals
Horizontal lines: Current swing high/low levels
Info label: Shows last detected swing levels
Optimal Conditions:
Timeframes: 1H, 4H, and Daily work best
Market Conditions: Ranging and trending markets both suitable
Volatility: Moderate to high volatility preferred
Session Times: Most effective during active trading sessions
Strengths:
✅ Exploits institutional manipulation tactics
✅ Clear entry/exit rules with defined risk
✅ Works across multiple asset classes
✅ Includes proper confirmation to reduce false signals
✅ Visual clarity for manual verification
✅ Reasonable risk/reward parameters
Limitations:
⚠️ Requires patience - not a high-frequency strategy
⚠️ Market dependent - fewer signals in low volatility periods
⚠️ Needs sufficient lookback data for swing identification
⚠️ May have drawdown periods during strong trending moves
⚠️ Requires understanding of market structure concepts
Best Practices for Users
Optimization Tips:
Adjust lookback period based on timeframe (shorter for lower TFs)
Test different confirmation periods for your market
Consider market session times when backtesting
Use alongside volume analysis for additional confirmation
Risk Management:
Never risk more than 2-3% per trade of total capital
Consider reducing position size during high-impact news
Monitor correlation if trading multiple pairs simultaneously
Use additional filters (trend, support/resistance) for confluence
Backtesting Recommendations:
Test on at least 6 months of historical data
Include different market conditions (trending, ranging, volatile)
Consider transaction costs and slippage in results
Forward test on demo before live implementation
Expected Results
Based on typical liquidity sweep strategy performance:
Disclaimer
This strategy is based on market structure analysis and institutional trading behavior patterns. Past performance doesn't guarantee future results. Users should:
Thoroughly backtest before live trading
Start with small position sizes
Understand the underlying concepts before implementation
Consider combining with other analysis methods
Always use proper risk management
The strategy works best when traders understand the psychological and structural elements of liquidity sweeps rather than just following signals blindly.
This Pine Script implements a Liquidity Sweep Trading Strategy, a sophisticated approach that capitalizes on market manipulation tactics commonly used by institutional traders. The strategy identifies when price "sweeps" above recent swing highs or below swing lows to trigger stop losses and grab liquidity, then quickly reverses direction - creating high-probability trading opportunities.
Core Concept: What is a Liquidity Sweep?
A liquidity sweep occurs when:
Price breaks above a swing high (or below a swing low) to trigger retail stop losses
Institutional players absorb this liquidity at favorable prices
Price quickly reverses back into the previous range
This creates a "fake breakout" or "stop hunt" pattern
The strategy exploits these manipulative moves by entering trades in the direction of the reversal.
How the Strategy Works
1. Swing Point Detection
Uses a lookback period (default: 20 bars) to identify significant swing highs and lows
Employs proper pivot point detection using ta.highestbars() and ta.lowestbars()
Only considers confirmed swing points (not just recent highs/lows)
2. Liquidity Sweep Identification
High Sweep (Short Setup):
Price moves above the last swing high (triggering buy stops)
Same bar closes back below the swing high (showing rejection)
Low Sweep (Long Setup):
Price moves below the last swing low (triggering sell stops)
Same bar closes back above the swing low (showing support)
3. Confirmation Process
Requires price to stay within the swept range for a specified number of bars (default: 3)
This confirms the sweep was genuine and not just normal volatility
Prevents false signals and improves trade quality
4. Entry Logic
Long Entries: Triggered after confirmed low sweeps
Short Entries: Triggered after confirmed high sweeps
5. Risk Management
Stop Loss: Placed at a multiple of ATR (default: 1.5x) from entry price
Take Profit: Risk/Reward ratio based (default: 2:1)
Position Sizing: 10% of equity per trade (configurable)
Red X-crosses: High sweeps detected
Green X-crosses: Low sweeps detected
Red triangles (down): Short entry signals
Green triangles (up): Long entry signals
Horizontal lines: Current swing high/low levels
Info label: Shows last detected swing levels
Optimal Conditions:
Timeframes: 1H, 4H, and Daily work best
Market Conditions: Ranging and trending markets both suitable
Volatility: Moderate to high volatility preferred
Session Times: Most effective during active trading sessions
Strengths:
✅ Exploits institutional manipulation tactics
✅ Clear entry/exit rules with defined risk
✅ Works across multiple asset classes
✅ Includes proper confirmation to reduce false signals
✅ Visual clarity for manual verification
✅ Reasonable risk/reward parameters
Limitations:
⚠️ Requires patience - not a high-frequency strategy
⚠️ Market dependent - fewer signals in low volatility periods
⚠️ Needs sufficient lookback data for swing identification
⚠️ May have drawdown periods during strong trending moves
⚠️ Requires understanding of market structure concepts
Best Practices for Users
Optimization Tips:
Adjust lookback period based on timeframe (shorter for lower TFs)
Test different confirmation periods for your market
Consider market session times when backtesting
Use alongside volume analysis for additional confirmation
Risk Management:
Never risk more than 2-3% per trade of total capital
Consider reducing position size during high-impact news
Monitor correlation if trading multiple pairs simultaneously
Use additional filters (trend, support/resistance) for confluence
Backtesting Recommendations:
Test on at least 6 months of historical data
Include different market conditions (trending, ranging, volatile)
Consider transaction costs and slippage in results
Forward test on demo before live implementation
Expected Results
Based on typical liquidity sweep strategy performance:
Disclaimer
This strategy is based on market structure analysis and institutional trading behavior patterns. Past performance doesn't guarantee future results. Users should:
Thoroughly backtest before live trading
Start with small position sizes
Understand the underlying concepts before implementation
Consider combining with other analysis methods
Always use proper risk management
The strategy works best when traders understand the psychological and structural elements of liquidity sweeps rather than just following signals blindly.
Script protégé
Ce script est publié en source fermée. Toutefois, vous pouvez l'utiliser librement et sans aucune restriction - en savoir plus ici.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script protégé
Ce script est publié en source fermée. Toutefois, vous pouvez l'utiliser librement et sans aucune restriction - en savoir plus ici.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.