OPEN-SOURCE SCRIPT
Sweep & Reverse | Liquidity Sweep Reversal Strategy

This strategy trades the liquidity-sweep reversal pattern: price wicks through a prior swing high or low — clearing out the stops resting there — then closes back inside the range, suggesting the move beyond that level was a stop-hunt rather than a genuine breakout.
How it works:
Confirmed swing highs and lows (via pivot detection) are stored as watched levels.
A sweep triggers when a bar wicks past a level but closes back on the other side.
Longs enter on swept lows, shorts on swept highs. The stop sits just beyond the sweeping wick (with an ATR buffer); the target is set from your chosen reward:risk ratio.
Levels expire if left untouched for too long, and new levels too close to an existing one (relative to ATR) are skipped to keep zones from cluttering.
Features:
Warnings:
This is fundamentally a mean-reversion pattern. In strongly trending markets, sweeps frequently continue rather than reverse — no combination of filters here eliminates that risk.
Backtest results are sensitive to pivot length, stop distance, and which filters are enabled. A high win rate on a small number of trades is not statistically meaningful — test across multiple instruments and timeframes, and evaluate profit factor and max drawdown alongside net profit, not net profit alone.
Past performance in a backtest, including this one, does not guarantee future results. This is not financial advice.
How it works:
Confirmed swing highs and lows (via pivot detection) are stored as watched levels.
A sweep triggers when a bar wicks past a level but closes back on the other side.
Longs enter on swept lows, shorts on swept highs. The stop sits just beyond the sweeping wick (with an ATR buffer); the target is set from your chosen reward:risk ratio.
Levels expire if left untouched for too long, and new levels too close to an existing one (relative to ATR) are skipped to keep zones from cluttering.
Features:
- Optional volume-spike filter — only counts sweeps backed by above-average volume
- Optional rejection-wick filter — requires the sweeping wick to be meaningfully larger than the bar's body, filtering out weak/low-conviction sweeps
- Optional next-bar confirmation — waits one bar past the sweep and only enters if price actually continues in the reversal direction, reducing whipsaw entries
- Optional session window filter (defaults to the London/NY overlap, the highest-liquidity window)
- Adjustable stop distance, minimum stop size, and reward:risk ratio
- Breakeven stop management once a trade moves partway to target
- Long/short can be toggled independently
- Every trade's entry/SL/TP lines persist on the chart after the trade closes (auto-expiring after a configurable number of bars), so past trades stay visible for review
- Styled performance dashboard: trade count, win rate, net profit, live position state
Warnings:
This is fundamentally a mean-reversion pattern. In strongly trending markets, sweeps frequently continue rather than reverse — no combination of filters here eliminates that risk.
Backtest results are sensitive to pivot length, stop distance, and which filters are enabled. A high win rate on a small number of trades is not statistically meaningful — test across multiple instruments and timeframes, and evaluate profit factor and max drawdown alongside net profit, not net profit alone.
Past performance in a backtest, including this one, does not guarantee future results. This is not financial advice.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.