In classical retail technical analysis, traders are taught that when price breaks above a previous swing high, it signifies a breakout and an opportunity to buy. However, in institutional algorithmic order flow, over 65% of swing high breaches are merely Liquidity Sweeps (Turtle Soups) designed to trigger retail stop-loss orders and fill institutional sell blocks.
To automate SMC (Smart Money Concepts) profitably in Pine Script v6, an algorithm must mathematically differentiate a Liquidity Sweep from a genuine Break of Structure (BOS).
The Structural Anatomy of a Sweep vs BOS
The distinction between a sweep and a continuation lies entirely in candle close validation and volume displacement:
- Liquidity Sweep (Reversal Setup): Price penetrates the swing high with an intrabar wick (
high > swingHigh), but the bar closes back inside the structural range (close < swingHigh). This traps breakout buyers and creates an immediate supply imbalance. - Break of Structure / BOS (Trend Continuation): Price penetrates the swing level and achieves a decisive candle body close above it (
close > swingHigh) accompanied by above-average volume or a Fair Value Gap (FVG).
Pine Script v6 Algorithmic Detection Logic
Below is a production Pine Script v6 architecture showing how to track structural swing points and flag sweeps vs BOS events using non-repainting arrays:
Ensuring Zero Repainting on Pivot Highs
TradingView built-in functions like ta.pivothigh() confirm pivots only after rightBars have closed. Plotting historical levels in real time without buffering can cause repainting. Always evaluate signals on confirmed bar closes (barstate.isconfirmed).
Combining Sweeps with Order Block Mitigation
A liquidity sweep alone is not enough for an entry. High-probability trade execution requires the sweep to interact with an unmitigated Order Block (OB) or Fair Value Gap (FVG). When an order block is tested and rejected on a higher timeframe, the lower timeframe sweep provides the exact trigger for entry with an asymmetric risk-to-reward ratio.
Institutional SMC Engine for TradingView
SmartCat Algo automates Order Block mapping, BOS/CHoCH transitions, and volume sweeps directly on your charts. Open-source Pine Script v6 code without recurring subscriptions.
Get SmartCat Algo (8 One-Time)