OPEN-SOURCE SCRIPT

Liquidity Pool Detector [EXCAVO]

1 963
Equal High/Low Cluster Detection with Sweep Identification and Period Reference Levels

The Liquidity Pool Detector identifies where resting orders accumulate near swing
levels by detecting equal highs and equal lows using swing pivot analysis with ATR-based
tolerance. When price wicks through a cluster level and closes back inside, the indicator
marks a sweep - the moment orders at that level were filled and price reversed direction.

This is not a basic pivot-high/low indicator. The cluster-merging logic groups nearby
pivots into unified levels with touch counts, and the sweep filter distinguishes between
a genuine zone test and a breakout continuation.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ HOW TO USE

Step 1 → Add the indicator to the price chart. Red solid lines appear above
price (equal highs clusters) and blue solid lines appear below price
(equal lows clusters). Previous day and week H/L reference levels
appear as slightly thicker dotted lines.
Step 2 → Watch for sweep markers. "Highs Swept" appears on a bar where price
wicked above an equal-highs cluster and closed back below it. "Lows
Swept" appears below a bar where price wicked below equal lows and
closed above. These bars indicate price tested and reversed from a cluster level.
Step 3 → Read the touch count on each cluster label. "Highs ×3" means three
swing highs formed at approximately the same level - a stronger cluster
with a stronger level formed by more historical touches.
Step 4 → Check the dashboard. Dist to High and Dist to Low show how many ATR
units separate current price from the nearest cluster above and below.
Values below 1.0 ATR highlight in orange - price is close to a level.
Nearest High and Nearest Low show the exact price of those levels.
Step 5 → Set up sweep alerts to receive notifications on bar close when a
cluster level is tested and rejected. Use JSON Alerts for bot integration.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ HOW IT CALCULATES

◆ Swing Pivot Detection
The indicator uses ta.pivothigh() and ta.pivotlow() with a configurable Swing Length
(default 3). A pivot high is confirmed when the bar's high is the highest point among
the surrounding N bars on each side - requiring N bars to the left and N bars to the
right, so detection occurs N bars after the actual pivot forms. This lag ensures the
pivot is fully confirmed and the value never changes after the bar closes. Lower Swing
Length values (2-3) suit intraday timeframes; higher values (5) suit daily charts.

◆ Cluster Merging (ATR Tolerance)
When a new confirmed pivot is detected, the indicator compares it against all existing
clusters of the same type. If the distance between the new pivot and an existing cluster
level is within the Equal Tolerance threshold (default 0.5 x ATR), the pivots are merged:
the cluster level is updated to the weighted average of all touches, and the touch count
increments. If no nearby cluster exists and the cluster limit has not been reached, a new
cluster is created at that price level. This approach prevents visual noise from minor
price variations between otherwise equal levels.

◆ Sweep Detection
On each confirmed bar close, every active cluster is checked against two conditions.
For equal-highs clusters: if the bar's high exceeded the cluster level AND the close is
below the cluster level, a sweep is registered - price moved through the zone of resting
orders and reversed. For equal-lows clusters: if the bar's low was below the cluster level
AND the close is above it, a sweep is registered. A close through the level without
reversal (close >= highs cluster, or close <= lows cluster) is treated as a breakout:
the cluster is invalidated and removed without a sweep marker.

◆ Period Reference Levels
Previous Day High/Low and Previous Week High/Low are fetched using request.security()
with a confirmed-bar offset (high[1] / low[1] with barmerge.lookahead_on). These levels
are included in the Nearest High and Nearest Low dashboard calculations alongside the
detected equal-high/low clusters.

◆ Non-Repainting Design
All cluster additions, sweep detections, and invalidations are gated on
barstate.isconfirmed. No cluster is created and no sweep marker is placed until the bar
closes. Pivot detection uses a right-bar offset that confirms the pivot on a fully closed
bar. No value changes after a bar is confirmed.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ WHAT MAKES IT DIFFERENT

◆ ATR-Based Cluster Tolerance
Most equal-high/low detectors use a fixed pip or percentage threshold that fails across
different instruments and timeframes. Using ATR as the tolerance baseline means the same
settings work on BTCUSD hourly (high ATR) and EURUSD daily (low ATR) without manual
recalibration. The tolerance adapts to current market conditions automatically.

◆ Cluster Merging with Touch Count
Instead of drawing a separate line for every swing pivot, nearby pivots are merged into a
single cluster with an incrementing touch count. A cluster labeled "Highs ×3" represents
three independent swing highs at the same level - a significantly stronger zone than a
single untested level. The line and label update in place as new touches are added.

◆ Sweep vs Breakout Distinction
The indicator explicitly separates sweep bars (wick through, close back inside) from
breakout bars (close through the level). A sweep generates a "Highs Swept" or "Lows
Swept" marker and an alert. A breakout silently removes the cluster. This distinction
matters: sweeps are potential reversal setups; breakouts confirm continuation.

◆ Period Levels as Part of the Analysis
Previous Day and Week H/L are integrated into the same framework as the equal-high/low
clusters. They appear in the Nearest High/Low dashboard calculation and use the same color
scheme as cluster lines, making them immediately readable alongside the dynamically
detected clusters.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ DASHBOARD

Compact panel showing current conditions:
  • Dist to High - distance from current price to nearest cluster above, in ATR units; turns orange below 1.0 ATR
  • Dist to Low - distance from current price to nearest cluster below, in ATR units; turns orange below 1.0 ATR
  • Nearest High - exact price of the closest active cluster or period level above
  • Nearest Low - exact price of the closest active cluster or period level below
  • Last Sweep - most recent sweep type: Highs Swept, Lows Swept, or - (none)
  • Swing - active swing length parameter


Legend table (bottom left) explains cluster lines, period levels, and sweep markers.
Both panels toggle in Dashboard settings.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ SETTINGS

Detection
  • Swing Length - 3 bars (pivot confirmation window left and right; use 2-3 for intraday, 5 for daily)
  • Equal Tolerance (x ATR) - 0.5 (cluster merge radius as ATR multiple)
  • Max Clusters - 10 (maximum active clusters tracked per direction)
  • Max Display Distance (x ATR) - 5.0 (clusters beyond this ATR distance from price are hidden; detection continues)


Period Levels
  • Show Prev Day H/L - ON (previous day high and low reference lines)
  • Show Prev Week H/L - ON (previous week high and low reference lines)


Visualization
  • Bull Color - default blue (equal-lows clusters and lows-swept markers)
  • Bear Color - default red (equal-highs clusters and highs-swept markers)
  • Sweep Color - default orange (sweep marker labels)
  • Show Sweep Markers - ON (labeled markers on sweep bars)
  • Background Highlight - OFF (subtle tint when price is within one ATR of nearest cluster)


Alerts
  • JSON Alerts - OFF (enable for bot integration)


Dashboard
  • Dashboard Position - Top Right
  • Show Dashboard - ON
  • Show Legend - ON


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ ALERTS

  • Highs Swept - price wicked above equal-highs cluster and closed below on bar close
  • Lows Swept - price wicked below equal-lows cluster and closed above on bar close
  • Any Sweep - any cluster level tested and rejected on bar close


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Best regards,
EXCAVO


Disclaimer
Trading involves significant risk. This indicator is a technical analysis tool
and does not constitute financial advice, investment recommendations, or a
guarantee of future results. Past indicator behavior does not guarantee future
performance. Always use proper risk management and your own judgment.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน