PROTECTED SOURCE SCRIPT

Liquidity Sweep Trap Alert (Improved)

984
Detects high-conviction “liquidity sweep” traps (false breakouts) by comparing price against recent swing highs/lows, applying a wick-size filter and a cooldown period so that only meaningful reversal wicks trigger signals.

Shows labels on the chart and provides alert conditions when a trap occurs.

How It Works (Core Concept)
Swing High / Low Sweep

The script looks back a user-defined number of bars (Lookback Period) to identify the most recent swing high and swing low (excluding the current forming bar).

A Bull Trap is identified when price’s high exceeds that swing high intrabar but the candle closes back below it.

A Bear Trap is identified when price’s low dips below that swing low intrabar but the candle closes back above it.

Wick-Size Filter

To avoid tiny “micro-sweeps,” the script measures the length of the reversal wick (the distance beyond the swing high or below the swing low) as a percentage of the bar’s total range.

Only if this wick percentage ≥ Min Wick/Range % does the raw trap condition qualify for further consideration.

Cooldown Mechanism

After a trap fires, the same type of trap (bull or bear) is suppressed for a specified number of bars (Cooldown Bars).

This prevents back-to-back signals in choppy conditions and ensures each trap has breathing room before the next.

Confirmed on Close

Signals only trigger once the bar has closed (barstate.isconfirmed), eliminating “ghost” signals that flash intrabar and then vanish.

Chart Labels & Alerts

When a trap is confirmed, a label (“Trap ↑” for bull, “Trap ↓” for bear) is plotted above/below the bar (toggleable via Show Trap Labels).

Built-in alertcondition calls allow users to create native TradingView alerts tied to these confirmed traps.

Inputs & Usage
Lookback Period (bars)

Defines how many bars back to compute the recent swing high/low.

Shorter values catch more frequent, smaller swings; longer values focus on larger pivots.

Show Trap Labels

Toggle on/off the on-chart label markers.

Cooldown Bars

Number of bars to wait after a trap fires before allowing the same trap type again.

Higher values reduce signal frequency; set lower if you want more frequent triggers.

Min Wick/Range %

Minimum required wick length (beyond the swing level) as a percentage of that bar’s high–low range.

Increase to filter out weak or noise-driven sweeps; decrease if you want to capture smaller reversals.

Recommended Settings & Markets
Timeframes: Works on any timeframe (e.g., 5m, 15m, 1h, daily). Adjust inputs per instrument volatility.

Crypto (e.g., BTC): Typical starting values might be Lookback = 10, Min Wick % = 0.10–0.20, Cooldown = 3–5 bars.

Equities / Indices (e.g., Nifty, Bank Nifty): Use higher Min Wick % (e.g., 0.30–0.50) and adjust volume-based filters externally. Cooldown may be 3–5 bars on daily charts.

Testing: Always backtest or visually review sample signals before live trading. Tune Lookback and Min Wick % to balance hit-rate vs. false positives.

Originality & What Makes It Different
Beyond Simple Breakout Alerts: Instead of alerting on any breakout, this indicator specifically looks for false breakouts (liquidity sweeps) where smart money may trap retail stops.

Wick-Size Threshold: Many scripts flag any high above a swing high; here, the reversal wick must be a configurable percentage of the bar’s range, filtering out minor spikes.

Cooldown Logic: Prevents repeated signals in tight ranges, unlike basic breakout or pivot indicators that may fire repeatedly.

Confirmed on Close: Eliminates intrabar flicker signals, ensuring each alert is based on a completed bar.

Lightweight & Self-Contained: No external dependencies; works standalone on the chart. Users can hook native TradingView alerts to these conditions.

How to Use
Add to Chart: Apply the published script; no need for additional overlays.

Configure Inputs: Open settings and set:

Lookback Period to match swing size you target.

Min Wick/Range % to filter out small reversals.

Cooldown Bars so signals aren’t clustered.

Toggle Show Trap Labels on/off.

Set Alerts: In TradingView Alerts, choose “Bull Trap Detected” or “Bear Trap Detected” as the condition.

Interpret Signals:

Bull Trap: Price tried to break above a recent high but failed—potential short opportunity or exit long.

Bear Trap: Price tried to break below a recent low but failed—potential long opportunity or exit short.

Combine with Risk Management: Always apply your own stop-loss and take-profit rules; use the trap signal as one element of your trade decision.

Chart Examples & Annotations
Clean Example Chart: Display only this indicator on the chart using default inputs or example settings.

Annotation Guidance: If you include manual drawings in screenshots, clearly explain:

“Red label marks the bar where price spiked above the 10-bar swing high, closed below it with wick ≥ 10% of range, and no prior bull trap in last 5 bars → Bull Trap.”

Avoid unrelated scripts or decorative drawings that aren’t described.

Disclaimer
Not Financial Advice: Signals indicate potential reversal setups but do not guarantee outcomes. Trade at your own risk.

Use Proper Risk Management: Always define stop-loss, position size, and consider market context.

Test Before Live: Review historical signals and backtest manually or via strategy tester if possible.

免責聲明

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