Liquidity Grab Reversal Indicator for TradingView — Free Open-Source PineScript v6 XAUUSD Gold Indicator
A premium-grade, 100% open-source PineScript v6 liquidity grab reversal indicator for gold (XAUUSD). It detects institutional stop hunts at liquidity pools, filters every signal through five accuracy layers — rejection wick, volume spike, sweep depth, breakout confirmation and EMA200 trend regime — then plots non-repainting BUY/SELL signals with ATR-based structural stop lines. Full source code included below, plus a tested accuracy-optimized 4H preset for XAUUSD.
Table of Contents
- What Is a Liquidity Grab Reversal?
- Why This Indicator Is Built for XAUUSD 4H
- Best Accuracy Preset for XAUUSD 4H
- Complete Input Parameters Reference
- How the Detection Engine Works (Step by Step)
- The 5 Accuracy Filters Explained
- Why This Indicator Never Repaints
- How to Install on TradingView
- How to Trade the BUY/SELL Signals
- Setting Up TradingView Alerts
- Open Source vs Paid SMC Indicators
- Frequently Asked Questions
1. What Is a Liquidity Grab Reversal?
A liquidity grab — also called a stop hunt or liquidity sweep — is the moment price spikes through an obvious swing high or swing low, triggers the resting stop-loss orders parked there by retail traders, and then violently reverses. Institutional players need liquidity to fill large orders, and those stop clusters are exactly where it lives.
The signature of a grab is threefold: the wick sweeps the level (not just a close), the candle closes back on the correct side, and the move is accompanied by above-average volume. This indicator automates the entire smart-money-concepts (SMC) detection chain — pivot confirmation, liquidity pooling, sweep identification, quality filtering and breakout entry confirmation — so you never have to eyeball it manually.
If you want the full manual framework behind this logic — including multi-timeframe bias and market structure shifts — read our Multi-Timeframe Liquidity Sweep Trading Strategy and the ICT Concepts Masterclass.
2. Why This Indicator Is Built for XAUUSD 4H
Gold is the most liquidity-hunted instrument in forex. XAUUSD's enormous average daily range means stop clusters above equal highs and below equal lows are dense, deep and repeatedly raided — especially during London and New York sessions. That makes XAUUSD the highest-probability hunting ground for a liquidity grab reversal indicator.
The 4H timeframe is the accuracy sweet spot:
| Why 4H for XAUUSD | Explanation |
|---|---|
| Noise vs signal | M5/M15 on gold is full of algorithmic noise that fakes sweeps; 4H filters it while still producing 5–10 setups per month. |
| Pivot quality | 4H swing highs/lows are institutionally relevant levels — each 4H bar is a full session segment, so pivots carry order-flow weight. |
| ATR stability | ATR(28) on 4H equals 7 full trading days — a stable volatility baseline that anchors the sweep-depth ceiling and stop offset. |
| Broker reality | Gold spreads are tightest in London/NY; 4H signals give you time to execute without chasing the tape. |
The preset in the next section is tuned specifically for this instrument-timeframe combination. For context on how 4H structure fits a complete XAUUSD plan, see our XAUUSD Market Structure Trading Strategy.
3. Best Accuracy Preset for XAUUSD 4H
This is the single best accuracy-focused configuration for XAUUSD · 4H, based on the indicator's own detection logic. Apply these values in the indicator's input panel (gear icon) after adding it to your chart:
| Input Parameter | XAUUSD 4H Preset | Why This Value |
|---|---|---|
| Liquidity H/Ls Look Back/Forward Period | 2 | Pivot period 2 = each swing must be confirmed by 2 bars on both sides. Captures institutional swing liquidity on gold 4H without over-detecting 1-bar noise. |
| ATR Length (number of bars back) | 28 | 28 four-hour bars ≈ 7 trading days — a calm, reliable volatility baseline for gold's wide swings. |
| Liquidity Grab by Close or High/Low | H/L | H/L mode requires the candle wick to physically sweep the level — a true stop hunt. Close-based grabs are looser and produce more false signals on XAUUSD. |
| Breakout entry confirmation | ON | BUY/SELL only fires after a closed candle breaks beyond the grab-candle extreme. Kills premature signals during the reversal battle. |
| Rejection wick filter | ON | The grab candle must close with a meaningful rejection wick — hard evidence that the sweep was rejected, not accepted. |
| Min rejection wick (%) | 40 | Gold's volatility makes 30% too loose. 40% demands unambiguous rejection — the wick is 40%+ of the candle's range. |
| Volume confirmation | ON | Real stop hunts print above-average volume. Signals without volume participation are excluded. |
| Volume spike multiplier | 1.3 | Volume must be 1.3× its 20-bar average. The default 1.2 catches normal gold volume noise; 1.3 isolates genuine stop-run participation. |
| Sweep depth ceiling | ON | Excludes sweeps that penetrate too deep — those are genuine breakouts, not grabs. |
| Max sweep depth (x ATR) | 0.75 | A sweep deeper than 0.75× ATR past the level signals real breakout intent. Below that threshold, it is statistically a grab. |
| Trend regime filter (EMA200) | ON | Long grabs only above the 200 EMA, short grabs only below. Trading with the macro trend has a statistically higher win rate on gold. |
| Show Long Liquidity Grabs | ON | Display bullish sweep-reversal signals (▲ grab markers, BUY labels). |
| Show Short Liquidity Grabs | ON | Display bearish sweep-reversal signals (▼ grab markers, SELL labels). |
| Show recommended stop lines | ON | Plots the ATR-based structural stop as a dashed line so risk is pre-defined on every signal. |
| Stop offset (x ATR) | 0.5 | Stop sits 0.5× ATR beyond the grab-candle extreme — wide enough to survive gold's wick volatility, tight enough to keep R:R attractive. |
Note: the four deviations from the built-in defaults are Look-Back Period 1→2, Min Rejection Wick 30→40, Volume Multiplier 1.2→1.3 and Trend Regime Filter OFF→ON. Every one of them raises signal quality at the cost of fewer (but better) signals — exactly what accuracy optimization means.
4. Complete Input Parameters Reference
All 18 adjustable inputs are grouped into four panels. "Default" is the built-in value; "4H Preset" is the XAUUSD accuracy configuration from Section 3.
CORE Group
| Input | Default | 4H Preset | Range / Options |
|---|---|---|---|
| Liquidity H/Ls Look Back/Forward Period | 1 | 2 | min 1 |
| ATR Length (number of bars back) | 28 | 28 | min 1 |
| Liquidity Grab by Close or High/Low | H/L | H/L | "H/L" or "Close" |
Entry Accuracy Group
| Input | Default | 4H Preset | Range / Options |
|---|---|---|---|
| Breakout entry confirmation | true | ON | bool |
| Rejection wick filter | true | ON | bool |
| Min rejection wick (%) | 30 | 40 | 5–80, step 5 |
| Volume confirmation | true | ON | bool |
| Volume spike multiplier | 1.2 | 1.3 | min 1.0, step 0.1 |
| Sweep depth ceiling | true | ON | bool |
| Max sweep depth (x ATR) | 0.75 | 0.75 | min 0.1, step 0.05 |
| Trend regime filter (EMA200) | false | ON | bool |
Display Group
| Input | Default | 4H Preset | Range / Options |
|---|---|---|---|
| Show Long Liquidity Grabs | true | ON | bool |
| Show Short Liquidity Grabs | true | ON | bool |
| Show recommended stop lines | false | ON | bool |
| Stop offset (x ATR) | 0.5 | 0.5 | min 0.1, step 0.1 |
Styling Group
| Input | Default | Range / Options |
|---|---|---|
| Long Liquidity Grabs Color (Green) | lime | color picker |
| Long Liquidity Grabs Transparency | 0 | 0–100 |
| Short Liquidity Grabs Color (Red) | red | color picker |
| Short Liquidity Grabs Transparency | 0 | 0–100 |
5. How the Detection Engine Works (Step by Step)
The indicator runs a five-phase pipeline on every confirmed (closed) bar. Understanding it lets you trust what you see — and tune inputs deliberately instead of randomly.
| Phase | What Happens | What You See |
|---|---|---|
| 1. Pivot confirmation | ta.pivothigh()/ta.pivotlow() confirm swing highs/lows only after the look-back period closes (non-repainting by construction). | Nothing yet — pivots are recorded internally. |
| 2. Liquidity pooling | Two pivots of the same type within ATR × 0.25 tolerance merge into a single liquidity level. The level extends right as a dotted line. | Dotted green (support) or red (resistance) liquidity line + diamond ◆ markers on both contributing pivots. |
| 3. Grab detection | H/L mode: a candle's wick sweeps the level and the candle closes back on the safe side (long: low sweeps support, close back above; short: high sweeps resistance, close back below). The level is consumed. | ▲ (long) or ▼ (short) grab marker on the sweep candle + solid "potential entry" line at the grab-candle extreme. |
| 4. Accuracy filters | The grab candle must pass every enabled filter (Section 6). Fail any one → setup silently discarded, level stays consumed. | No new drawing if filters fail. |
| 5. Breakout confirmation | A later closed candle closes beyond the entry line (long: close > grab-candle high; short: close < grab-candle low). Only then does the signal fire. | BUY/SELL label + triangle plotshape + optional dashed ATR stop line. Alert triggers. |
This pipeline is what separates the indicator from 90% of free "liquidity" scripts on TradingView: it does not fire on a bare wick through a line. It requires pivot-verified liquidity, a filtered rejection candle, and a closed-bar breakout confirmation before committing to a signal.
6. The 5 Accuracy Filters Explained
Each filter is independently toggleable, so you can A/B test configurations and see exactly what each layer removes from your chart.
1. Breakout entry confirmation. The grab candle proves the hunt happened; it does not prove the reversal will follow. This filter withholds the BUY/SELL until a completed candle closes beyond the grab-candle extreme (high for longs, low for shorts). This is the single biggest false-signal killer in the entire script.
2. Rejection wick filter. A reversal candle must reject. The filter measures the protective wick as a percentage of the candle's full range (long: close−low ÷ range; short: high−close ÷ range) and requires it to meet the minimum (40% in the preset). A sweep candle that closes at its extreme is continuation, not reversal.
3. Volume confirmation. Institutional participation leaves footprints. Grab-candle volume must exceed the 20-bar average volume × the multiplier (1.3× in the preset). Thin-volume sweeps are usually retail noise.
4. Sweep depth ceiling. How deep the wick pierced the level is measured in ATR multiples. A shallow pierce (≤0.75 ATR) is a grab; a deep run-through is a genuine breakout. The ceiling automatically disqualifies the latter so you never fade a real breakout.
5. Trend regime filter (EMA200). Long setups are only accepted when price is above the 200 EMA and short setups only below it. Statistically, trend-aligned liquidity grabs have a materially higher win rate — counter-trend sweeps often keep running.
7. Why This Indicator Never Repaints
"Non-repainting" is the most abused claim in indicator marketing. This script earns it through four structural guarantees in the code:
| Guarantee | Implementation |
|---|---|
| Closed bars only | The entire detection pipeline runs inside barstate.isconfirmed — nothing is evaluated on a forming candle, so nothing can change after the fact. |
| Confirmed pivots | ta.pivothigh()/ta.pivotlow() only return values once the full look-back/forward window has closed — a pivot can never vanish or relocate. |
| Chronological separation | A level can never be grabbed on the bar it is created (createBar < bar_index), so freshly-drawn lines cannot instantly "self-trigger". |
| Delayed confirmation | Breakout confirmation requires a later closed candle beyond the entry price. Once a signal fires, it is permanently stored and never moved or deleted. |
You can verify this yourself: run the indicator on a chart, note every signal bar, refresh the page, and step through history — every marker stays exactly where it was first printed.
8. How to Install on TradingView (Free Plan Works)
| Step 1 | Open TradingView → any XAUUSD 4H chart (works on the free plan, no subscription needed). |
| Step 2 | Click Pine Editor at the bottom of the screen, delete the template code. |
| Step 3 | Copy the full PineScript v6 source from the code block below (use the Copy button) and paste it into the editor. |
| Step 4 | Click Save, then Add to chart. |
| Step 5 | Click the indicator name on the chart → gear icon → apply the XAUUSD 4H preset from Section 3. |
Full Open-Source PineScript v6 Source Code
The complete, unmodified source of the Liquidity Grab Reversal indicator. Free to use, inspect and modify. 372 lines, zero dependencies, TradingView-native functions only.
9. How to Trade the BUY/SELL Signals
The indicator gives you the setup. Discipline gives you the edge. Here is the complete execution rulebook for the XAUUSD 4H preset:
| Component | Rule |
|---|---|
| Entry (long) | Enter on the close of the BUY signal candle — the first 4H candle that closes above the grab-candle high. No limit-order games; confirmation is the point. |
| Entry (short) | Enter on the close of the SELL signal candle — the first 4H candle that closes below the grab-candle low. |
| Stop loss | The dashed recommended stop line — 0.5× ATR beyond the grab-candle extreme. Never widen it after entry; a touched stop means the grab failed. |
| Take profit | 2R at minimum, then trail. The natural target is the opposite-side liquidity pool — the same kind of level this indicator draws on the other side of the range. |
| Risk per trade | 1% of equity or less. Use our Lot Size Calculator to convert the stop distance into position size in one click. |
| Sessions | London and New York opens produce the highest-quality gold sweeps. 4H candles that close during the Asian session are statistically weaker. |
| News filter | Skip signals within 1 hour of NFP, CPI or FOMC — red-folder events override technical structure. Check our Live Economic Calendar before every trade. |
For the deeper strategy layer — how to read the sweep within market structure, where to place partials, and prop-firm compliance — read the Multi-Timeframe Liquidity Sweep Strategy and our Liquidity Trap Trading Strategy guide.
10. Setting Up TradingView Alerts
The indicator exposes two built-in alert conditions — Long Liquidity Grab and Short Liquidity Grab — which fire exactly when a confirmed BUY/SELL signal prints:
| Step 1 | Right-click the chart → Add alert. |
| Step 2 | Condition → Liquidity Grab Reversal → select Long Liquidity Grab or Short Liquidity Grab (create one alert for each). |
| Step 3 | Trigger → Once per bar close (matches the indicator's closed-bar logic). |
| Step 4 | Notification → TradingView app push, email, or webhook to your own server/Telegram bot. |
Want the same logic trading automatically on MetaTrader instead of alerting you manually? We convert PineScript strategies into full MQL4/MQL5 Expert Advisors with identical filters and risk logic — see our PineScript to MT4/MT5 Conversion service.
11. Open Source vs Paid SMC Indicators
Most "premium" liquidity indicators sold for $50–$300 are closed-source boxes that repaint in backtests. This indicator is fully open: every line is visible above, every filter is toggleable, and the non-repaint behavior is verifiable by reading the code rather than trusting a sales page. That is why we publish the complete source rather than hiding it behind an invitation-only script.
| Feature | Liquidity Grab Reversal (free) | Typical Paid SMC Indicator |
|---|---|---|
| Source code | 100% open, in this article | Locked, invitation-only |
| Non-repaint proof | Verifiable in code (barstate.isconfirmed + delayed confirmation) | Trust-me marketing |
| Filter stack | 5 toggleable accuracy layers | Often just pivot lines + candles |
| Price | Free, no signup | $50–$300 |
| Alerts | Built-in (2 conditions) | Varies |
| Customization | Full — edit the PineScript freely | Inputs only |
Browse more free institutional-grade tools in our Indicators Library, free EAs in Free EA Downloads, or grab verified XAUUSD history to backtest this indicator's logic from our Historical Data Library.
Frequently Asked Questions
Is the Liquidity Grab Reversal indicator really free and open source?
Yes. The complete PineScript v6 source is published in this article. Copy it into the TradingView Pine Editor, use it on any account type, modify it, and keep your modified version. There is no signup, no trial, and no hidden paid tier.
What is the best timeframe and preset for XAUUSD gold?
The 4H timeframe with the accuracy preset in Section 3: pivot period 2, ATR 28, H/L grab mode, 40% min rejection wick, 1.3× volume spike, 0.75 ATR sweep ceiling, EMA200 trend filter ON, stop lines ON at 0.5× ATR. This configuration maximizes signal quality on gold while staying tradeable with 5–10 setups per month.
Does this indicator repaint or recalculate past signals?
No. Everything is evaluated on confirmed (closed) bars only, pivots finalize only after their look-back window closes, and the breakout confirmation requires a later closed candle. Once a BUY/SELL label prints, it never moves, changes or disappears. You can verify this by refreshing your chart and comparing history.
How accurate is the liquidity grab reversal signal on XAUUSD?
The five filter layers exist precisely to remove the low-quality sweeps that make naive liquidity strategies lose money. Signals that pass all five filters are high-probability by construction, but no indicator is a holy grail. Trade them with the 1:2+ R:R, 1% risk and news filter from Section 9, and combine with 4H market structure analysis for the best results.
Can I use it on EURUSD, BTCUSD, US30 or other symbols?
Yes — liquidity grabs are a market-wide phenomenon. Keep ATR length 28 and sweep depth 0.75, but raise the minimum rejection wick for calmer pairs (40–50%) and lower the volume multiplier to 1.2 if your feed's volume profile is flatter. The XAUUSD preset is tuned for gold's specific volatility.
How do I get an alert when a signal fires?
Right-click the chart → Add alert → condition "Liquidity Grab Reversal" → "Long Liquidity Grab" or "Short Liquidity Grab" → trigger "Once per bar close" → choose push, email or webhook. Create two alerts (one per direction). See Section 10 for the exact steps.
Can this PineScript indicator be converted to an MT4/MT5 Expert Advisor?
Yes — and that is exactly what we do professionally. The logic converts 1:1 into MQL4/MQL5 (pivots, ATR, filters and breakout confirmation all have native equivalents), turning this into a fully automated gold EA. See our PineScript Conversion and Pine Script Development services for fixed-price quotes.
Automate This Exact Logic as an MT4/MT5 Gold EA
The same five-filter liquidity grab engine — converted to MQL4/MQL5 with position sizing, news filtering and prop-firm guardrails. Fixed price, full source code included.