OPEN-SOURCE SCRIPT

Session Sweep Detector | AlphaScript

3 814
🎯Session Sweep Detector
Tracks the High and Low of the Asia and London sessions and tells you exactly what happened to each level — using strict, transparent definitions.

🔍What it does
When a session closes, its High and Low become fixed liquidity levels.
This indicator draws each level from the exact candle that printed the extreme and watches it until the same session opens again the next day.

Each level resolves in exactly one of three ways:

⚡ SWEEP — price wicks through the level but the bar closes back on the original side. A liquidity raid: stops were taken, but the level held on a closing basis.

💥BREAK — a bar closes through the level. This is not a sweep, and the indicator never labels it as one. Breaks are displayed separately (and can be hidden) so the two events are never conflated.

🛡️Untouched — the level survives its full watch window without either event.
First qualifying event wins: one outcome per level, per session, per day. If a bar both pierces and closes through a level, it counts as a break — a close through the level can never be a sweep.

📖How to read the chart

-Solid colored lines are session levels. Each line starts at the candle that actually made the High or Low, so the line points at the liquidity itself.

-Live levels (still being watched) project ahead of price with a name and price label.

-After a sweep or break, the tag prints at the event bar and the line continues a configurable number of bars past the event before freezing — so you can see the reaction.

-Levels that were never touched freeze when their watch window ends.

⚙️Settings

-Toggle each level independently (Asia High/Low, London High/Low), with per-session colors and fully configurable session hours (times in New York time; defaults: Asia 18:00–04:00, London 03:00–12:00).

-Minimum wick penetration filter (in ticks) to ignore marginal pokes when qualifying sweeps. Does not apply to breaks.

-Control how many previous sessions' levels and tags remain on the chart, with optional transparency for past levels.

-Optional Opening Range Block overlay (off by default): draws the opening range of the New York, London, or Asia session with configurable duration, breakout arrows, mid line, and previous-range history. Note: ORB breakout detection and alerts only run while the ORB display is enabled.

🔔Alerts
Per-level sweep alerts (Asia High/Low, London High/Low), combined "Any Sweep" and "Any Break" alerts, and ORB breakout alerts. All alerts fire on the close of the event bar.

📌 Notes and limitations

-Designed for intraday timeframes (1 minute to 30 minutes). On higher timeframes, sessions span too few bars for meaningful detection.

-Session times are defined in New York time (America/New_York) and handle the midnight crossover correctly. If you use another session-levels indicator, match the session hours so both tools agree on where the levels are.

-Sweep-vs-break classification depends on your chart timeframe: a wick-through-and-reclaim on a 15m bar may resolve as a break on 1m if an intermediate bar closed beyond the level. Neither reading is wrong — they are answers to different questions — but be aware of it when comparing timeframes.

✅Why no repaint

-Events are evaluated on confirmed (closed) bars only. A sweep or break tag will never appear intrabar and then vanish.

-Levels are only armed after their session has fully completed. A session High that is still forming cannot be "swept" — price touching it would simply extend it — so no detection runs until the level is final.

-No request.security() calls are used anywhere. All session tracking is chart-timeframe state.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.