OPEN-SOURCE SCRIPT
Liquidity Sweep Reaction Grid [PhenLabs]

📊 Liquidity Sweep Reaction Grid [PhenLabs]
Version: PineScript™ v6

📌 Description
The Liquidity Sweep Reaction Grid (LSRG) is a full-stack sweep detection and reaction classification engine that maps probable sweep zones, scores their structural quality, and labels the outcome — continuation, reclaim, or failure — directly on the chart. Unlike generic liquidity level tools that only show where sweeps may occur, LSRG tells you how convincing the sweep was and what likely happens next.
Every sweep event is evaluated across five independent quality factors: volumetric pressure, wick-to-body rejection ratio, close-back strength, higher-timeframe bias alignment, and session context. The result is a 1–5 star quality score displayed at the sweep bar, allowing traders to immediately distinguish between a genuine displacement sweep and low-conviction wick noise. Only sweeps meeting a configurable score threshold generate the post-event classification labels, keeping the chart readable and actionable.
LSRG is designed as a high-signal context layer — not a standalone entry trigger. It identifies the structural conditions that precede high-probability reactions and gives traders a systematic framework for evaluating sweep quality at a glance.
🚀 Points of Innovation
🔧 Core Components
🔥 Key Features
🎨 Visualization
📖 Usage Guidelines
Sweep Detection
Pivot Lookback
Default: 10 | Range: 3–50
Bars left and right used for swing high/low confirmation. Higher values = fewer but more significant pivots.
ATR Length
Default: 14 | Range: 1–100
ATR period for wick size normalization and band width calculation.
Min Sweep Size (ATR×)
Default: 0.5 | Range: 0.1–5.0
Minimum wick extension beyond the pivot level, expressed as an ATR multiple. Increase to filter out smaller, less significant sweeps.
Volume Z-Score Min
Default: 1.0 | Range: 0.0–4.0
Minimum rolling volume z-score required to qualify a sweep. Set to 0 to disable volume filtering; increase to 1.5–2.0 for more selective confirmation.
Max Active Zones
Default: 20 | Range: 5–50
Maximum number of sweep zones displayed simultaneously. Older zones are automatically removed when the cap is reached.
HTF Bias
Enable HTF Bias
Default: On
Enables the higher-timeframe EMA calculation and bias line overlay.
HTF Timeframe
Default: 240 (4H)
Timeframe used for the bias EMA. Select a timeframe at least 4× higher than your chart timeframe for meaningful macro context.
HTF EMA Length
Default: 50 | Range: 5–200
EMA length applied to the higher-timeframe close. Shorter values react faster but may produce more noise.
Reaction Scoring
Show Quality Score
Default: On
Displays the ★N/5 score label at each sweep bar.
Min Score to Label
Default: 3 | Range: 1–5
Only sweeps meeting or exceeding this score will generate CONT / RECLAIM / FAIL outcome labels. Set to 4–5 for highly selective labeling; set to 1–2 for broader coverage.
Session Weighting
Session Weighting
Default: On
Enables the session-context factor in the quality score.
NY / London Open Windows
Default: 09:30–11:00 / 03:00–05:00 (Exchange time)
Configure to match your broker’s session hours or your preferred high-participation windows.
Session Score Boost
Default: 1 | Range: 0–2
Points added to the quality score when a sweep occurs within an active session window.
✅ Best Use Cases
⚠️ Limitations
💡 What Makes This Unique
🔬 How It Works
1. Pivot-based liquidity mapping:
Swing highs and lows are confirmed using ta.pivothigh() and ta.pivotlow() with configurable left/right lookback. These represent the most recent confirmed liquidity pools above (swing highs) and below (swing lows) current price. All sweep measurements reference these confirmed levels.
2. Sweep detection and volume confirmation:
A bull sweep fires when price wicks below the most recent swing low by at least the ATR minimum threshold and closes back above it in the same bar, with volume z-score meeting the configured minimum. The symmetric condition applies for bear sweeps above swing highs. This combination of price and volume criteria filters out low-participation wick extensions.
3. Five-factor quality scoring:
At each confirmed sweep bar, five binary factors are evaluated independently: (1) volume z-score exceeds threshold + 0.5 for a strong spike, (2) wick size exceeds body size by at least 2× indicating a rejection candle, (3) close-back retracement is ≥ 0.5 ATR above/below the swept level, (4) HTF bias aligns with the sweep direction, (5) sweep occurs within an active session window. Each true factor adds one point to a 0–5 score (capped at 5 including any session boost).
4. Band drawing and zone management:
Qualified sweep events generate an ATR-proportional box extending forward from the sweep bar for the configured number of bars. Boxes are tracked in an array capped at the Max Active Zones setting — oldest zones are automatically deleted when the cap is reached, preventing chart object accumulation.
5. Post-event classification:
Each sweep above the minimum score threshold is registered as an open SweepEvent. After a configurable offset period, price behavior is evaluated each bar: continuation fires if price moves ≥1 ATR in the sweep direction past the swept level; reclaim fires on a clean close-back; failure fires when price closes through the level in the opposite direction. Events that remain unresolved for more than 50 bars are automatically expired.
All content provided by PhenLabs is for informational and educational purposes only. Past performance does not guarantee future results.
Version: PineScript™ v6
📌 Description
The Liquidity Sweep Reaction Grid (LSRG) is a full-stack sweep detection and reaction classification engine that maps probable sweep zones, scores their structural quality, and labels the outcome — continuation, reclaim, or failure — directly on the chart. Unlike generic liquidity level tools that only show where sweeps may occur, LSRG tells you how convincing the sweep was and what likely happens next.
Every sweep event is evaluated across five independent quality factors: volumetric pressure, wick-to-body rejection ratio, close-back strength, higher-timeframe bias alignment, and session context. The result is a 1–5 star quality score displayed at the sweep bar, allowing traders to immediately distinguish between a genuine displacement sweep and low-conviction wick noise. Only sweeps meeting a configurable score threshold generate the post-event classification labels, keeping the chart readable and actionable.
LSRG is designed as a high-signal context layer — not a standalone entry trigger. It identifies the structural conditions that precede high-probability reactions and gives traders a systematic framework for evaluating sweep quality at a glance.
🚀 Points of Innovation
- Five-factor reaction quality score (★1–★5) evaluated independently at each sweep bar — separates displacement events from wick noise with a single glance
- Post-event classification labels (▶ CONT / ↩ RECLAIM / ✕ FAIL) resolve automatically after the sweep, removing the guesswork of manual outcome tracking
- HTF bias integration: higher-timeframe EMA is used as a directional filter, meaning sweeps aligned with HTF momentum receive boosted quality scores and are plotted in bias-consistent color
- Session-aware weighting: NY open and London open windows automatically boost sweep quality scores, reflecting the elevated institutional participation and displacement probability during these periods
- ATR-proportional sweep bands: zone width is normalized to current volatility rather than a fixed price offset, making the bands meaningful and comparable across instruments and timeframes
🔧 Core Components
- Swing Pivot Engine: Uses confirmed pivot highs and lows (configurable lookback, no future reference) as the baseline liquidity levels that sweeps are measured against
- ATR Wick Classifier: Measures wick extension beyond the pivot in ATR units — only wicks meeting the minimum ATR multiplier threshold qualify as candidate sweeps
- Volume Z-Score Filter: Computes a rolling 20-bar volume z-score and requires a minimum threshold for sweep confirmation, ensuring volumetric participation is present
- Reaction Quality Scorer: Evaluates five independent binary factors (volume spike, wick dominance, close-back strength, HTF alignment, session context) and sums them into a 0–5 score
- SweepEvent State Machine: Tracks each qualified sweep as an open event and evaluates price behavior in subsequent bars to classify the outcome as continuation, reclaim, or failure
- HTF Bias Layer: Pulls the higher-timeframe EMA via request.security with lookahead_off and uses it both as a visual reference line and as a quality scoring input
🔥 Key Features
- Quality Score Labels (★N/5): Displayed directly on the sweep bar — configure the minimum score required before outcome labels are generated to control label density
- Dynamic Sweep Bands: ATR-proportional boxes extend forward from each sweep event, visually marking the reaction zone for the configured number of bars
- Outcome Classification Labels: ▶ CONT fires when price moves ≥1 ATR in the sweep direction; ↩ RECLAIM fires on a clean close-back to the level; ✕ FAIL fires when price closes back through the swept level in the opposite direction
- Session Window Boost: NY and London open session windows are fully configurable — sweeps occurring in these periods receive an automatic score boost reflecting higher institutional participation probability
- Live Info Table: Top-right table shows current HTF bias direction, session status, volume z-score, and ATR at a glance without cluttering the main chart
- 4 Alert Conditions: Bull Sweep Detected, Bear Sweep Detected, High-Quality Bull Sweep, High-Quality Bear Sweep — all configurable with full message context including ticker, interval, and score
🎨 Visualization
- Sweep Bands: Teal boxes for bull sweeps (below swing lows), red boxes for bear sweeps (above swing highs) — width is ATR × 0.3, extending forward for the configured bar count
- HTF Bias Line: Thin EMA line at the higher-timeframe price level — teal when HTF is bullish, red when bearish — provides macro directional context without cluttering the overlay
- Quality Score Labels: ★N/5 displayed below/above the sweep bar in the band color — immediately readable quality assessment at the event bar
- Outcome Labels: ▶ CONT (teal), ↩ RECLAIM (orange), ✕ FAIL (red) — placed at the bar where the post-sweep condition resolves, offset from price to avoid overlap
- Sweep Signal Markers: Small triangles below (bull) and above (bear) the sweep bar — visible in the data window and usable as alert sources
📖 Usage Guidelines
Sweep Detection
Pivot Lookback
Default: 10 | Range: 3–50
Bars left and right used for swing high/low confirmation. Higher values = fewer but more significant pivots.
ATR Length
Default: 14 | Range: 1–100
ATR period for wick size normalization and band width calculation.
Min Sweep Size (ATR×)
Default: 0.5 | Range: 0.1–5.0
Minimum wick extension beyond the pivot level, expressed as an ATR multiple. Increase to filter out smaller, less significant sweeps.
Volume Z-Score Min
Default: 1.0 | Range: 0.0–4.0
Minimum rolling volume z-score required to qualify a sweep. Set to 0 to disable volume filtering; increase to 1.5–2.0 for more selective confirmation.
Max Active Zones
Default: 20 | Range: 5–50
Maximum number of sweep zones displayed simultaneously. Older zones are automatically removed when the cap is reached.
HTF Bias
Enable HTF Bias
Default: On
Enables the higher-timeframe EMA calculation and bias line overlay.
HTF Timeframe
Default: 240 (4H)
Timeframe used for the bias EMA. Select a timeframe at least 4× higher than your chart timeframe for meaningful macro context.
HTF EMA Length
Default: 50 | Range: 5–200
EMA length applied to the higher-timeframe close. Shorter values react faster but may produce more noise.
Reaction Scoring
Show Quality Score
Default: On
Displays the ★N/5 score label at each sweep bar.
Min Score to Label
Default: 3 | Range: 1–5
Only sweeps meeting or exceeding this score will generate CONT / RECLAIM / FAIL outcome labels. Set to 4–5 for highly selective labeling; set to 1–2 for broader coverage.
Session Weighting
Session Weighting
Default: On
Enables the session-context factor in the quality score.
NY / London Open Windows
Default: 09:30–11:00 / 03:00–05:00 (Exchange time)
Configure to match your broker’s session hours or your preferred high-participation windows.
Session Score Boost
Default: 1 | Range: 0–2
Points added to the quality score when a sweep occurs within an active session window.
✅ Best Use Cases
- Identifying high-conviction sweep events during NY or London open as potential reversal or continuation setups
- Filtering out low-quality sweeps (★1–★2) from higher-quality displacement events (★4–★5) when making context decisions
- Confirming breakout or breakdown levels: a ▶ CONT label after a sweep in the HTF bias direction is a strong structural confirmation signal
- Trap identification: ✕ FAIL labels at bear sweeps above resistance during a bullish HTF bias flag probable bull traps
- Multi-timeframe confluence: use LSRG on the 1H or 4H with a 1D HTF bias to identify sweeps that align with daily structure
⚠️ Limitations
- LSRG is a context and confirmation layer — it is not designed or tested as a standalone entry system and should always be used alongside price action analysis
- The five-factor quality score is rule-based and does not adapt to regime shifts; high-volatility news events can produce inflated volume z-scores that temporarily override the filter
- Volume data quality varies significantly across exchanges and brokers — results on instruments with low or synthetic volume (e.g., some CFDs) will be degraded
- Pivot lookback creates an inherent delay equal to the lookback period — sweep detection fires at the close of the pivot confirmation bar, not in real-time as the wick forms
- HTF bias reflects EMA trend direction, not immediate momentum — it may lag during sharp reversals
💡 What Makes This Unique
- Quality scoring at sweep detection: No other public sweep tool evaluates five independent factors at the event bar and displays a composite score — this is the primary differentiator from liquidity level overlays
- Automated outcome classification: The CONT / RECLAIM / FAIL label system resolves post-sweep behavior automatically, giving traders a structured outcome framework without manual tracking
- Session-aware quality weighting: Sweep events during NY and London opens receive elevated scores reflecting historical institutional participation patterns — a rarely implemented but highly relevant context factor
🔬 How It Works
1. Pivot-based liquidity mapping:
Swing highs and lows are confirmed using ta.pivothigh() and ta.pivotlow() with configurable left/right lookback. These represent the most recent confirmed liquidity pools above (swing highs) and below (swing lows) current price. All sweep measurements reference these confirmed levels.
2. Sweep detection and volume confirmation:
A bull sweep fires when price wicks below the most recent swing low by at least the ATR minimum threshold and closes back above it in the same bar, with volume z-score meeting the configured minimum. The symmetric condition applies for bear sweeps above swing highs. This combination of price and volume criteria filters out low-participation wick extensions.
3. Five-factor quality scoring:
At each confirmed sweep bar, five binary factors are evaluated independently: (1) volume z-score exceeds threshold + 0.5 for a strong spike, (2) wick size exceeds body size by at least 2× indicating a rejection candle, (3) close-back retracement is ≥ 0.5 ATR above/below the swept level, (4) HTF bias aligns with the sweep direction, (5) sweep occurs within an active session window. Each true factor adds one point to a 0–5 score (capped at 5 including any session boost).
4. Band drawing and zone management:
Qualified sweep events generate an ATR-proportional box extending forward from the sweep bar for the configured number of bars. Boxes are tracked in an array capped at the Max Active Zones setting — oldest zones are automatically deleted when the cap is reached, preventing chart object accumulation.
5. Post-event classification:
Each sweep above the minimum score threshold is registered as an open SweepEvent. After a configurable offset period, price behavior is evaluated each bar: continuation fires if price moves ≥1 ATR in the sweep direction past the swept level; reclaim fires on a clean close-back; failure fires when price closes through the level in the opposite direction. Events that remain unresolved for more than 50 bars are automatically expired.
💡 Note: LSRG measures the structural quality of liquidity sweep events. It does not predict price direction with certainty, and quality score thresholds should be calibrated to the instrument and timeframe being traded. All outcome labels are based on defined price conditions — they describe what happened structurally, not what will happen next. Use as one input in a broader analytical framework.
All content provided by PhenLabs is for informational and educational purposes only. Past performance does not guarantee future results.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
TradingView Charting w/ Crypto Systems: phenlabs.com
Join our growing community: discord.gg/phen
All content provided by PhenLabs is for informational & educational purposes only. Past performance does not guarantee future results.
Join our growing community: discord.gg/phen
All content provided by PhenLabs is for informational & educational purposes only. Past performance does not guarantee future results.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
TradingView Charting w/ Crypto Systems: phenlabs.com
Join our growing community: discord.gg/phen
All content provided by PhenLabs is for informational & educational purposes only. Past performance does not guarantee future results.
Join our growing community: discord.gg/phen
All content provided by PhenLabs is for informational & educational purposes only. Past performance does not guarantee future results.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.