OPEN-SOURCE SCRIPT
Mis à jour

HTF Session Sweep Model

887
HTF Session Sweep Model [NICK789]

The HTF Session Sweep Model is a session-based market structure tool designed to help traders observe how price interacts with the previous confirmed higher-timeframe candle during active trading sessions.

This script was created because session trading can become messy when traders manually mark multiple highs, lows, opens, boxes, sweeps, breakouts, and traps across different timeframes. Instead of adding unrelated indicators together, this model uses one central reference point: the previous confirmed HTF candle. Once an enabled session begins, the script maps that HTF candle’s high, low, midpoint, and optional session open level onto the chart. Price action during that session is then classified around that reference range.

The purpose of the script is not to predict price. The purpose is to provide a clean framework for reading session behaviour around a higher-timeframe range.

Core Concept

The script is built around the idea that the previous higher-timeframe candle can provide useful reference levels for intraday price behaviour. Its high and low can act as areas where liquidity may be taken, where breakouts may develop, or where failed breakouts may occur.

The model does not project the HTF candle before the session opens. It activates when an enabled session opens. At that point, it takes the most recent fully confirmed HTF candle and uses it as the active session reference.

This creates a consistent question for the trader:

How is price reacting around the previous confirmed HTF candle during the current session?

What Makes This Script Original

This script is not designed as a simple combination of unrelated indicators. The components are connected through one session-based model:

1. Session engine
The script allows users to enable Asia, London, and New York sessions. Each session can use its own time window and timezone setting.

2. HTF reference map
At the start of an enabled session, the script maps the previous confirmed HTF candle. This includes the HTF high, low, midpoint, optional candle body, and optional session open level.

3. Sweep model
The script checks whether price sweeps above the HTF high or below the HTF low. Users can choose between a basic wick sweep or a stricter sweep that requires price to close back inside the HTF range.

4. Delivery shift confirmation
After a sweep occurs, the script can wait for a delivery shift confirmation before marking a sweep entry. A bearish confirmation requires price to break below a recent low range after a high sweep. A bullish confirmation requires price to break above a recent high range after a low sweep.

5. Breakout model
If price closes and holds outside the HTF range, the script can classify the move as a breakout. Users can set how many bars price must hold beyond the range.

6. Displacement filter
The breakout model can optionally require stronger candle movement by comparing the candle body against ATR. This helps filter weaker breaks that do not show meaningful displacement.

7. Failed breakout trap model
If price breaks beyond the HTF high or low and then returns back inside the range, the script can classify that move as a failed breakout trap. A Bull Trap means price broke above the HTF high and failed back inside. A Bear Trap means price broke below the HTF low and failed back inside.

These parts work together because they all answer the same question: did price sweep the HTF range, accept beyond it, or fail after breaking it?

How The Script Calculates The Model

When a new enabled session begins, the script requests the previous confirmed candle from the selected higher timeframe. The selected HTF may be adjusted by the user, such as 1H, 2H, 4H, Daily, or Weekly.

The script then stores the following values:

* Previous HTF open
* Previous HTF high
* Previous HTF low
* Previous HTF close
* Previous HTF midpoint
* Current session open

These values become the session reference map.

During the active session, the script checks price against the HTF high and low.

High Sweep:
A high sweep is detected when price trades above the previous HTF high.

Low Sweep:
A low sweep is detected when price trades below the previous HTF low.

Close Back Inside Sweep Mode:
When this stricter mode is selected, a high sweep requires price to close back below the HTF high. A low sweep requires price to close back above the HTF low.

Sweep Entry:
A sweep entry is not triggered by the sweep alone. After a sweep, the script waits for a delivery shift confirmation using the selected lookback length.

Breakout Long:
A breakout long is detected when price closes above the HTF high and holds above it for the selected number of bars.

Breakout Short:
A breakout short is detected when price closes below the HTF low and holds below it for the selected number of bars.

Bull Trap:
A bull trap is detected when price breaks above the HTF high but later closes back below the HTF high.

Bear Trap:
A bear trap is detected when price breaks below the HTF low but later closes back above the HTF low.

Volume Filter:
The optional volume filter compares current volume against a moving average of volume multiplied by the selected volume multiplier. When enabled, sweep and breakout conditions must also pass the volume filter.

Bar Close Confirmation:
The script includes an option to confirm signals only after the bar closes. This is enabled by default to make signals more stable for alerts and historical review.

How To Use This Script

1. Choose the reference timeframe
Select the HTF candle you want to use as the session reference. Intraday traders may use 1H, 2H, or 4H. Higher-timeframe traders may prefer Daily or Weekly.

2. Enable the sessions you trade
The script supports Asia, London, and New York sessions. Users can enable or disable each session and adjust the session window and timezone.

3. Watch the HTF range during the session
Once the session opens, the script draws the previous confirmed HTF candle range. The high and low are the main reaction levels.

4. Read price behaviour around the range
If price sweeps a level and returns inside, it may indicate a liquidity sweep.
If price closes and holds outside the range, it may indicate breakout continuation.
If price breaks outside and then returns inside, it may indicate a failed breakout trap.

5. Use the labels as classifications, not automatic trade commands
The labels are designed to classify price behaviour. They are not guaranteed buy or sell signals.

6. Combine with your own confirmation
Users should combine this model with their own market context, risk management, higher-timeframe bias, and execution plan.

Main Visual Elements

HTF Range Box:
Shows the previous confirmed HTF candle range during the active session.

HTF Candle Display:
Optionally displays the previous HTF candle body and wick on the chart.

High and Low Lines:
Marks the previous HTF high and low.

Midpoint Line:
Marks the midpoint of the HTF range.

Session Open Line:
Marks the price at the open of the active session.

Sweep Marks:
Marks when price sweeps above or below the HTF range.

Sweep Entry Marks:
Marks when a sweep is followed by delivery shift confirmation.

Breakout Marks:
Marks when price closes and holds outside the HTF range.

Trap Marks:
Marks failed breakout conditions as Bull Trap or Bear Trap.

Dashboard:
Optional compact dashboard showing the current session, HTF reference, confirmation mode, state, high, low, and midpoint.

Important Settings

Reference HTF Candle:
Controls which higher timeframe is used for the previous confirmed candle reference.

Sweep Mode:
Choose between Wick Sweep or Wick Sweep + Close Back Inside.

Confirm Signals On Bar Close:
When enabled, signals confirm after candle close. This is recommended for cleaner historical review and alerts.

Delivery Shift Lookback:
Controls how many bars are used to confirm a shift after a sweep.

Breakout Hold Bars:
Controls how many bars price must remain outside the HTF range before a breakout is confirmed.

Displacement Filter:
Requires the candle body to be large enough compared with ATR before confirming a breakout.

Volume Filter:
Optional filter requiring current volume to exceed average volume by the selected multiplier.

Keep Historical Sessions:
When disabled, the chart stays cleaner by only showing the current/latest session map. When enabled, historical session maps can remain visible, with a limit to reduce chart clutter.

Visual Modes:
Clean mode is designed for normal use.
Stealth mode reduces visual intensity.
Debug mode makes internal reference levels easier to inspect.

Alerts

The script includes alert conditions for:

* HTF high swept
* HTF low swept
* Sweep short
* Sweep long
* Breakout long
* Breakout short
* Bull trap
* Bear trap
* Master alert for any model event

The master alert is included so users can create one alert condition instead of setting up many separate alerts.

Recommended Use

This script is best suited for traders who use session timing, higher-timeframe ranges, liquidity sweeps, breakout continuation, and failed breakout concepts.

It may be useful on intraday charts where Asia, London, and New York session behaviour matters. It can also be adjusted for different markets and timeframes by changing the reference HTF and session settings.

Limitations

This script does not predict future price movement. It classifies how price behaves around the previous confirmed HTF candle during active sessions.

A sweep does not guarantee a reversal.
A breakout does not guarantee continuation.
A trap does not guarantee a full trend change.
Volume data may behave differently depending on the market and symbol.
Session behaviour can vary across forex, crypto, futures, indices, and stocks.

This tool should be used as a market structure framework, not as a standalone trading system.

Originality And Usefulness Statement

The originality of this script is in how it combines session timing, previous confirmed HTF candle mapping, sweep classification, breakout confirmation, and failed breakout detection into one connected workflow.

The script is useful because it gives traders a structured way to observe whether price is taking liquidity, accepting outside a higher-timeframe range, or failing after a breakout attempt. Each component supports the same central model rather than acting as an unrelated indicator mashup.

Disclaimer

This indicator is for educational and analytical use only. It is not financial advice and does not guarantee trading results. Users are responsible for their own trading decisions, testing, and risk management.
Notes de version
added POC, VAH, VAL
Notes de version
.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.