OPEN-SOURCE SCRIPT
Liquidity Sweep Probability

Stop-hunt detection with dynamic zone rendering and statistical edge validation
Identifies liquidity sweeps — moments when price briefly wicks beyond a significant high or low, clears resting stop orders, then reverses sharply back inside. Tracks whether each sweep type has historically produced a follow-through move and highlights the 3 most contextually relevant zones based on what is currently visible on your chart.
Sweep detection
A sweep is confirmed when:
Price wicks beyond the highest high or lowest low of the previous N bars by at least min_pts
The bar closes back inside that level
The wick represents stop orders being triggered (the liquidity grab). The close back inside confirms the reversal has begun.
Dynamic zone rendering
Rather than cluttering the chart with every historical sweep, the indicator identifies the 3 most recent sweep events within your current visible chart window and renders only those as blue horizontal zones. As you scroll or zoom, the zones update automatically to reflect the 3 most recent events in view. The zone spans the swept price range (wick extreme to close) and extends forward by a configurable number of bars.
Post-sweep confluence
After a sweep, two additional patterns are tracked:
Fair Value Gap (FVG) — a 3-candle price imbalance forming in the reversal direction while the scoring window is active. Represents unfilled price inefficiency that may act as support or resistance. Shown as dashed purple zones, also limited to 3 most recent in view.
Gap B — a traditional price gap where the bar opens completely beyond the previous bar's extreme. Rarer on MGC due to near-24-hour trading, but meaningful when it occurs around the 6 PM session open.
Statistical confidence
The same probability engine used across the suite: uncapped wins/total observation counts feed the binomial z-score and t-test. Zones are only rendered when the binomial z-score exceeds the significance threshold (default 1.282, p < 0.10). The dashboard shows both the all-history probability and the recent-3 probability, with dual display triggered automatically when they diverge by 10 percentage points or more.
Inputs
Level lookback (bars defining the significant high/low)
Minimum sweep size in points
Reversal window (minutes) and threshold (points)
Significance threshold for zone display
Zone width and transparency
FVG and Gap B toggles
Identifies liquidity sweeps — moments when price briefly wicks beyond a significant high or low, clears resting stop orders, then reverses sharply back inside. Tracks whether each sweep type has historically produced a follow-through move and highlights the 3 most contextually relevant zones based on what is currently visible on your chart.
Sweep detection
A sweep is confirmed when:
Price wicks beyond the highest high or lowest low of the previous N bars by at least min_pts
The bar closes back inside that level
The wick represents stop orders being triggered (the liquidity grab). The close back inside confirms the reversal has begun.
Dynamic zone rendering
Rather than cluttering the chart with every historical sweep, the indicator identifies the 3 most recent sweep events within your current visible chart window and renders only those as blue horizontal zones. As you scroll or zoom, the zones update automatically to reflect the 3 most recent events in view. The zone spans the swept price range (wick extreme to close) and extends forward by a configurable number of bars.
Post-sweep confluence
After a sweep, two additional patterns are tracked:
Fair Value Gap (FVG) — a 3-candle price imbalance forming in the reversal direction while the scoring window is active. Represents unfilled price inefficiency that may act as support or resistance. Shown as dashed purple zones, also limited to 3 most recent in view.
Gap B — a traditional price gap where the bar opens completely beyond the previous bar's extreme. Rarer on MGC due to near-24-hour trading, but meaningful when it occurs around the 6 PM session open.
Statistical confidence
The same probability engine used across the suite: uncapped wins/total observation counts feed the binomial z-score and t-test. Zones are only rendered when the binomial z-score exceeds the significance threshold (default 1.282, p < 0.10). The dashboard shows both the all-history probability and the recent-3 probability, with dual display triggered automatically when they diverge by 10 percentage points or more.
Inputs
Level lookback (bars defining the significant high/low)
Minimum sweep size in points
Reversal window (minutes) and threshold (points)
Significance threshold for zone display
Zone width and transparency
FVG and Gap B toggles
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.