OPEN-SOURCE SCRIPT
4H Liquidity Sweeps

═══════════════════════════════════════════════════════════════════════
4H Liquidity Sweeps — graded, with target and R:R
═══════════════════════════════════════════════════════════════════════
WHAT IT DOES
Marks higher-timeframe swing highs and lows that get wicked through and
rejected, then scores each one and projects where the resulting move is
aimed. Most sweep indicators stop at "a level was taken." This one asks
the two questions that decide whether the sweep is worth anything: how
long had that level been sitting there, and is there anything on the
other side to trade toward.
THE IDEA
A swing high or low is a shelf of resting orders — protective stops from
traders positioned into the swing, and breakout orders from traders
waiting for it to give way. When price trades through that shelf and
closes back inside, the move through it found no continuation, and every
order filled beyond the level is immediately offside.
That makes the sweep itself the setup's trigger, not the trade. The trade
is the return leg, and its natural destination is the nearest untouched
shelf on the opposite side. The indicator tracks both ends of that: the
level being taken, and the level being aimed at.
HOW IT WORKS
Levels
Swing highs and lows are confirmed on the sweep timeframe (default 4H,
independent of your chart timeframe) using a configurable pivot
strength. Equal highs and lows resolve to the first of the pair, so
double tops and bottoms still produce a level. Up to N unswept levels
per side are tracked and drawn as dotted lines.
Sweep detection
A level is swept when an HTF bar trades through it and closes back
inside. Three optional filters refine this:
• Minimum penetration — the wick must exceed the level by a set
fraction of ATR(14), so one-tick clips are ignored.
• Displacement rejection — the sweep bar must also close back inside
the PREVIOUS HTF bar's range (Loose) or beyond its midpoint
(Strict). This is what separates a genuine rejection from the first
bar of a breakout that happened to clip an old level on its way
past. Without it, a strongly trending bar can satisfy the level test
while price is plainly still expanding.
• Killzone — sweeps outside your chosen sessions are either dropped
entirely, or capped at B-grade.
A level that is CLOSED through rather than wicked through is deleted,
not marked. That is a break, not a sweep, and it is the main reason
the chart stays readable.
Grading
Every sweep is scored A, B or C from two measurements:
• Level age — how many HTF bars the level survived before it was
taken. This does most of the work. A level that sat for two days
accumulated orders; one from six hours ago did not.
• Reward — R:R from the projected entry to the nearest unswept level
on the opposite side.
A-grade needs both thresholds (default: 12 bars, 3.0R), B-grade the
looser pair (6 bars, 2.0R). Anything else is C and is hidden by
default, including any sweep with no unswept level to aim at.
Trade plan
On each qualifying sweep the indicator projects:
• Entry — an optimal-trade-entry retracement (default 0.705) of the
sweep bar, or the swept level itself if you prefer.
• Stop — beyond the sweep wick, buffered by a fraction of ATR(14).
• Target — the nearest unswept HTF level on the opposite side.
Each is drawn and labelled with its price, and the resulting R:R is
printed on the sweep label. Hover any label for the full breakdown:
grade, level age, killzone status, entry, stop, target, exact R:R.
WHAT YOU SEE
Dotted grey line : an unswept level, extending to the current bar
Solid line : a swept level, drawn from the swing to the bar that took it (thicker for A-grade)
Red zone / the sweep : level to wick extreme
Green zone / the reaction leg : level to the running extreme since the sweep, growing bar by bar until price loses back through the level or the window expires
Dashed line : the target
Dotted lines : entry and stop
SETTINGS WORTH KNOWING
Pivot strength :2 by default. Raise to 3–4 for fewer, more significant levels.
Level age :the filter to adjust first. Loosen this before you :touch the R:R thresholds.
Displacement : Loose is a sensible default; Strict will roughly halve your A-grade count.
Hide historical : keeps only the last N sweeps on the chart and erases everything older — useful for a live chart where only what is still in play matters.
ALERTS
Graded sweep (A or B) — fires only on setups that pass both filters
4H high swept / 4H low swept — directional
4H sweep (any)
NOTES AND LIMITATIONS
• Chart timeframe must be equal to or lower than the sweep timeframe.
The script raises an error otherwise.
• Nothing repaints. Higher-timeframe data is requested with lookahead
disabled, and every sweep is evaluated only against completed HTF
bars. A sweep therefore prints when its HTF bar closes, and a level
is confirmed a few bars after the swing that formed it — that is
confirmation lag, not repainting, and it is inherent to pivots.
• The green reaction zone updates as the move develops. It is live
state, not a signal.
• The R:R shown is calculated from an entry proxy taken on the sweep
bar itself. If you enter from a lower-timeframe structure shift
instead, your actual entry — and therefore your actual R:R — will
differ. Treat the printed figure as a screening number.
• Killzone membership is decided by the HTF bar's OPEN time. On a 4H
chart that means the session setting selects the bar CONTAINING the
killzone rather than the killzone itself, so the defaults are
deliberately widened. Narrow them if you lower the sweep timeframe.
• This is an analysis tool, not a strategy, and it is not backtested
within TradingView. It marks structure and projects levels; it makes
no claim about outcomes. Nothing here is financial advice — do your
own testing and manage your own risk.
4H Liquidity Sweeps — graded, with target and R:R
═══════════════════════════════════════════════════════════════════════
WHAT IT DOES
Marks higher-timeframe swing highs and lows that get wicked through and
rejected, then scores each one and projects where the resulting move is
aimed. Most sweep indicators stop at "a level was taken." This one asks
the two questions that decide whether the sweep is worth anything: how
long had that level been sitting there, and is there anything on the
other side to trade toward.
THE IDEA
A swing high or low is a shelf of resting orders — protective stops from
traders positioned into the swing, and breakout orders from traders
waiting for it to give way. When price trades through that shelf and
closes back inside, the move through it found no continuation, and every
order filled beyond the level is immediately offside.
That makes the sweep itself the setup's trigger, not the trade. The trade
is the return leg, and its natural destination is the nearest untouched
shelf on the opposite side. The indicator tracks both ends of that: the
level being taken, and the level being aimed at.
HOW IT WORKS
Levels
Swing highs and lows are confirmed on the sweep timeframe (default 4H,
independent of your chart timeframe) using a configurable pivot
strength. Equal highs and lows resolve to the first of the pair, so
double tops and bottoms still produce a level. Up to N unswept levels
per side are tracked and drawn as dotted lines.
Sweep detection
A level is swept when an HTF bar trades through it and closes back
inside. Three optional filters refine this:
• Minimum penetration — the wick must exceed the level by a set
fraction of ATR(14), so one-tick clips are ignored.
• Displacement rejection — the sweep bar must also close back inside
the PREVIOUS HTF bar's range (Loose) or beyond its midpoint
(Strict). This is what separates a genuine rejection from the first
bar of a breakout that happened to clip an old level on its way
past. Without it, a strongly trending bar can satisfy the level test
while price is plainly still expanding.
• Killzone — sweeps outside your chosen sessions are either dropped
entirely, or capped at B-grade.
A level that is CLOSED through rather than wicked through is deleted,
not marked. That is a break, not a sweep, and it is the main reason
the chart stays readable.
Grading
Every sweep is scored A, B or C from two measurements:
• Level age — how many HTF bars the level survived before it was
taken. This does most of the work. A level that sat for two days
accumulated orders; one from six hours ago did not.
• Reward — R:R from the projected entry to the nearest unswept level
on the opposite side.
A-grade needs both thresholds (default: 12 bars, 3.0R), B-grade the
looser pair (6 bars, 2.0R). Anything else is C and is hidden by
default, including any sweep with no unswept level to aim at.
Trade plan
On each qualifying sweep the indicator projects:
• Entry — an optimal-trade-entry retracement (default 0.705) of the
sweep bar, or the swept level itself if you prefer.
• Stop — beyond the sweep wick, buffered by a fraction of ATR(14).
• Target — the nearest unswept HTF level on the opposite side.
Each is drawn and labelled with its price, and the resulting R:R is
printed on the sweep label. Hover any label for the full breakdown:
grade, level age, killzone status, entry, stop, target, exact R:R.
WHAT YOU SEE
Dotted grey line : an unswept level, extending to the current bar
Solid line : a swept level, drawn from the swing to the bar that took it (thicker for A-grade)
Red zone / the sweep : level to wick extreme
Green zone / the reaction leg : level to the running extreme since the sweep, growing bar by bar until price loses back through the level or the window expires
Dashed line : the target
Dotted lines : entry and stop
SETTINGS WORTH KNOWING
Pivot strength :2 by default. Raise to 3–4 for fewer, more significant levels.
Level age :the filter to adjust first. Loosen this before you :touch the R:R thresholds.
Displacement : Loose is a sensible default; Strict will roughly halve your A-grade count.
Hide historical : keeps only the last N sweeps on the chart and erases everything older — useful for a live chart where only what is still in play matters.
ALERTS
Graded sweep (A or B) — fires only on setups that pass both filters
4H high swept / 4H low swept — directional
4H sweep (any)
NOTES AND LIMITATIONS
• Chart timeframe must be equal to or lower than the sweep timeframe.
The script raises an error otherwise.
• Nothing repaints. Higher-timeframe data is requested with lookahead
disabled, and every sweep is evaluated only against completed HTF
bars. A sweep therefore prints when its HTF bar closes, and a level
is confirmed a few bars after the swing that formed it — that is
confirmation lag, not repainting, and it is inherent to pivots.
• The green reaction zone updates as the move develops. It is live
state, not a signal.
• The R:R shown is calculated from an entry proxy taken on the sweep
bar itself. If you enter from a lower-timeframe structure shift
instead, your actual entry — and therefore your actual R:R — will
differ. Treat the printed figure as a screening number.
• Killzone membership is decided by the HTF bar's OPEN time. On a 4H
chart that means the session setting selects the bar CONTAINING the
killzone rather than the killzone itself, so the defaults are
deliberately widened. Narrow them if you lower the sweep timeframe.
• This is an analysis tool, not a strategy, and it is not backtested
within TradingView. It marks structure and projects levels; it makes
no claim about outcomes. Nothing here is financial advice — do your
own testing and manage your own risk.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。