OPEN-SOURCE SCRIPT

Liquidity Sweep Detector [Proozac]

420
# Liquidity Sweep Detector

**Pine Script v6 — Overlay Indicator**

---

## What It Does

Detects two related concepts from institutional liquidity theory:

1. **Equal Highs / Equal Lows (EQH / EQL)** — price levels where the market reached the same high or low on two separate occasions. These levels concentrate retail stop orders (buy stops above EQH, sell stops below EQL) and act as magnets for institutional order flow.

2. **Liquidity Sweep** — when price breaks through an EQH or EQL with a wick but *closes back on the opposite side*. This is the signal that institutions triggered the stops, absorbed that liquidity, and are now positioned in the opposite direction — the classic "stop hunt" or "liquidity grab."

---

## Detection Logic

### Equal Highs / Equal Lows

```
EQH: two pivot highs within a configurable % tolerance of each other
EQL: two pivot lows within a configurable % tolerance of each other
```

The indicator finds swing highs and lows via `ta.pivothigh` / `ta.pivotlow`. For each new pivot it compares against the 5 most recent ones. If the relative difference is within the `Equal Level Tolerance %` threshold, a dashed line is drawn between the two points and labelled `EQH` or `EQL`.

### Bullish Sweep (long signal)

```
wick_low < EQL AND close > EQL AND open > EQL
```

The wick pierces below an equal low but the candle body closes above it. Price swept the sell stops and snapped back — potential bullish reversal.

### Bearish Sweep (short signal)

```
wick_high > EQH AND close < EQH AND open < EQH
```

The wick pierces above an equal high but the candle body closes below it. Price swept the buy stops and snapped back — potential bearish reversal.

---

## Inputs

| Input | Default | Description |
|-------|---------|-------------|
| **Swing Length (Pivot)** | 10 | Bars required on each side to confirm a swing. Higher = fewer but more reliable pivots |
| **Equal Level Tolerance %** | 0.1 | Percentage margin for two pivots to be considered "equal". Increase for volatile assets |
| **Max Lookback for Equal Levels** | 50 | How far back to search for matching pivot levels |
| **Equal Highs Line Color** | Red | Color for EQH lines |
| **Equal Lows Line Color** | Green | Color for EQL lines |
| **Bearish Sweep Color** | Bright Red | Color for bearish sweep signal and candle |
| **Bullish Sweep Color** | Bright Green | Color for bullish sweep signal and candle |
| **Show Equal Level Lines** | true | Toggle EQH/EQL lines on/off |
| **Show Sweep Signals** | true | Toggle triangle signals on/off |
| **Show Sweep Labels** | true | Toggle "BULL SWEEP" / "BEAR SWEEP" labels on/off |

---

## Visual Signals

| Element | Description |
|---------|-------------|
| Red dashed line + "EQH" label | Liquidity pool at highs |
| Green dashed line + "EQL" label | Liquidity pool at lows |
| Green triangle below bar + label | Bullish sweep detected (potential long entry) |
| Red triangle above bar + label | Bearish sweep detected (potential short entry) |
| Candle color change | The sweep candle is highlighted in the signal color |

---

## How to Use

**Basic setup:**
1. Add to any chart (works best on 15m, 1H, 4H timeframes).
2. Look for confluence: a sweep on an EQL that also sits on a demand zone or Order Block produces the highest-conviction signals.
3. Enter on the candle after the sweep, stop below the sweep candle's wick low (bullish) or above the wick high (bearish).

**Setting up alerts:**
Three `alertcondition` entries are built in and ready to use:
- `Bullish Liquidity Sweep`
- `Bearish Liquidity Sweep`
- `Any Liquidity Sweep`

In TradingView: Alerts → Condition → select the indicator → choose the desired alert type.

---

## Configuration Tips

| Asset type | Recommended tolerance |
|---|---|
| Forex majors | 0.05 – 0.1 % |
| Crypto (BTC/ETH) | 0.2 – 0.5 % |
| Futures / indices | 0.05 – 0.15 % |

- A higher `Swing Length` (15–20) produces fewer, more confirmed signals. A lower value (5–7) is more reactive but generates more false positives.
- EQH/EQL lines do not extend into the future — they naturally disappear once swept, which is exactly the point of interest.

---

## Conceptual Background

Based on the **ICT (Inner Circle Trader)** and **Smart Money Concepts** framework: large operators need liquidity to fill their positions. Equal highs and equal lows are the zones where retail stop orders accumulate. The institutional player pushes price into those levels, harvests the liquidity, then reverses — that reversal move is the entry opportunity.

This is different from a breakout strategy. A sweep signal is *not* a breakout confirmation — it is a **failed breakout** that indicates smart money is positioned against the breakout direction.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.