OPEN-SOURCE SCRIPT

Swing High/Low with Liquidity Sweeps

94
🧠 Overview
This indicator identifies swing highs and swing lows based on user-defined candle lengths and checks for liquidity sweeps—situations where the price breaks a previous swing level but then closes back inside, indicating a potential false breakout or stop hunt. It also supports visual labeling and alerts for these events.

⚙️ Inputs
Swing Length (must be odd number ≥ 3):
Determines how many candles are used to identify swing highs/lows. The central candle must be higher or lower than all neighbors within the range.
Example: If swingLength = 5, the central candle must be higher/lower than the 2 candles on both sides.

Sweep Lookback (bars):
Defines how many bars to look back for possible liquidity sweeps.

Show Swing Labels (checkbox):
Optionally display labels on the chart when a swing high or low is detected.

Show Sweep Labels (checkbox):
Optionally display labels on the chart when a liquidity sweep occurs.

🕯️ Swing Detection Logic
A Swing High is detected when the high of the central candle is greater than the highs of all candles around it (as per the defined length).

A Swing Low is detected when the low of the central candle is lower than the lows of surrounding candles.

Swing labels are placed slightly above (for highs) or below (for lows) the candle.

💧 Liquidity Sweep Logic
A Sweep High is triggered if:

The current high breaks above a previously detected swing high,

And then the candle closes below that swing high,

Within the configured lookback window.

A Sweep Low is triggered if:

The current low breaks below a previous swing low,

And then closes above it,

Within the lookback window.

These are often seen as stop hunts or fake breakouts.

🔔 Alerts
Sweep High Alert: Triggered when a sweep above a swing high occurs.

Sweep Low Alert: Triggered when a sweep below a swing low occurs.

You can use these to set up TradingView alerts to notify you of potential liquidity grabs.

📊 Use Cases
Identifying market structure shifts.

Spotting fake breakouts and potential reversals.

Assisting in smart money concepts and liquidity-based trading.

Supporting entry timing in trend continuation or reversal strategies.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。