PROTECTED SOURCE SCRIPT
VSA Patterns & Liquidity Sweep

Description:
Overview This script creates a synergy between Volume Spread Analysis (VSA) and Institutional Liquidity concepts. The primary problem with standard VSA pattern detection is that high-volume rejection candles often appear randomly during strong trends, leading to false reversal signals.
To solve this, this indicator combines a custom Liquidity Persistence Algorithm with Strict VSA Pattern Recognition. The logic dictates that a VSA Reversal pattern (like a Shakeout or Upthrust) is statistically significant only if it occurs immediately following a "Sweep" of a key structural pivot (Liquidity Zone).
CONCEPTS & CALCULATIONS
1. The Liquidity Filter (Structure) Instead of using standard support/resistance, this script detects "Resting Liquidity" using Swing Highs and Swing Lows (ta.pivothigh / ta.pivotlow).
Persistence Logic: A unique feature of this script is "Level Persistence." When price pierces a pivot level, the level does not disappear immediately. It remains active for a user-defined period (default 5 bars). This accounts for "Stop Hunts" or "Double Taps" where price lingers beyond a level before reversing.
The Filter: The script records the timestamp of the last "Sweep" (when price breached a pivot). If a VSA pattern forms, the script calculates the delta between the Pattern Bar and the Last Sweep Bar. If the gap is within the tolerance threshold (e.g., 3 bars), the pattern is validated.
2. VSA Pattern Recognition (Volume & Shape) The script detects four specific VSA anomalies. These are not standard candlestick patterns; they are defined by rigid Volume and Wick-to-Body ratios:
Shakeout (SO): Detects a "Smart Money" trap where price is driven down to trigger stops and then reversed.
Logic: Requires rising volume (Vol > Vol[1] > Vol[2]) + a massive lower wick (default >40% of range) + a small upper wick.
Upthrust (UT): The bearish inverse of a Shakeout.
Logic: High volume rejection of higher prices with a long upper wick (>40% of range).
Two Bar Reversal (TBR): A reversal pattern that compares the current bar's close/low against the previous bar's high/close.
Logic: Strict checks on Close > High[1] (Bullish) combined with volume validation.
Engulfing Volume Reversal (EVR): A custom variation of the engulfing candle.
Logic: It requires the engulfing wick to exceed the body size by a ratio of 0.5 (configurable), ensuring the move is volatility-driven, not just a small candle engulfing a smaller candle.
HOW TO USE
Wait for Liquidity Lines: The script automatically plots Red (Resistance) and Teal (Support) lines from pivots.
Watch for Sweeps: Wait for price to trade through these lines (the line will turn dashed or fade, indicating a sweep).
Pattern Confirmation:
Diamonds (SO/UT): Indicate high-volatility rejections.
Triangles (TBR): Indicate immediate structure shifts.
Squares (EVR): Indicate volume-backed engulfing moves.
Alerts: The script includes a "Preview" mode for live trading but alerts are hard-coded to fire only on Bar Close to prevent repainting/false signals.
SETTINGS
Candle Shape: Users can relax or tighten the definition of a "Long Wick" (default 40%) to fit different asset volatilities (e.g., Crypto vs. Forex).
Liquidity Persistence: Adjust how long a level remains "active" after being broken.
Liquidity Filter On/Off: Traders can disable the filter to see raw VSA patterns for backtesting purposes.
Overview This script creates a synergy between Volume Spread Analysis (VSA) and Institutional Liquidity concepts. The primary problem with standard VSA pattern detection is that high-volume rejection candles often appear randomly during strong trends, leading to false reversal signals.
To solve this, this indicator combines a custom Liquidity Persistence Algorithm with Strict VSA Pattern Recognition. The logic dictates that a VSA Reversal pattern (like a Shakeout or Upthrust) is statistically significant only if it occurs immediately following a "Sweep" of a key structural pivot (Liquidity Zone).
CONCEPTS & CALCULATIONS
1. The Liquidity Filter (Structure) Instead of using standard support/resistance, this script detects "Resting Liquidity" using Swing Highs and Swing Lows (ta.pivothigh / ta.pivotlow).
Persistence Logic: A unique feature of this script is "Level Persistence." When price pierces a pivot level, the level does not disappear immediately. It remains active for a user-defined period (default 5 bars). This accounts for "Stop Hunts" or "Double Taps" where price lingers beyond a level before reversing.
The Filter: The script records the timestamp of the last "Sweep" (when price breached a pivot). If a VSA pattern forms, the script calculates the delta between the Pattern Bar and the Last Sweep Bar. If the gap is within the tolerance threshold (e.g., 3 bars), the pattern is validated.
2. VSA Pattern Recognition (Volume & Shape) The script detects four specific VSA anomalies. These are not standard candlestick patterns; they are defined by rigid Volume and Wick-to-Body ratios:
Shakeout (SO): Detects a "Smart Money" trap where price is driven down to trigger stops and then reversed.
Logic: Requires rising volume (Vol > Vol[1] > Vol[2]) + a massive lower wick (default >40% of range) + a small upper wick.
Upthrust (UT): The bearish inverse of a Shakeout.
Logic: High volume rejection of higher prices with a long upper wick (>40% of range).
Two Bar Reversal (TBR): A reversal pattern that compares the current bar's close/low against the previous bar's high/close.
Logic: Strict checks on Close > High[1] (Bullish) combined with volume validation.
Engulfing Volume Reversal (EVR): A custom variation of the engulfing candle.
Logic: It requires the engulfing wick to exceed the body size by a ratio of 0.5 (configurable), ensuring the move is volatility-driven, not just a small candle engulfing a smaller candle.
HOW TO USE
Wait for Liquidity Lines: The script automatically plots Red (Resistance) and Teal (Support) lines from pivots.
Watch for Sweeps: Wait for price to trade through these lines (the line will turn dashed or fade, indicating a sweep).
Pattern Confirmation:
Diamonds (SO/UT): Indicate high-volatility rejections.
Triangles (TBR): Indicate immediate structure shifts.
Squares (EVR): Indicate volume-backed engulfing moves.
Alerts: The script includes a "Preview" mode for live trading but alerts are hard-coded to fire only on Bar Close to prevent repainting/false signals.
SETTINGS
Candle Shape: Users can relax or tighten the definition of a "Long Wick" (default 40%) to fit different asset volatilities (e.g., Crypto vs. Forex).
Liquidity Persistence: Adjust how long a level remains "active" after being broken.
Liquidity Filter On/Off: Traders can disable the filter to see raw VSA patterns for backtesting purposes.
保護スクリプト
このスクリプトのソースコードは非公開で投稿されています。 ただし、制限なく自由に使用できます – 詳細はこちらでご確認ください。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。
保護スクリプト
このスクリプトのソースコードは非公開で投稿されています。 ただし、制限なく自由に使用できます – 詳細はこちらでご確認ください。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。