OPEN-SOURCE SCRIPT
Key Level Sweep & Breakout

█ OVERVIEW
Key Level Sweep & Breakout is a multi-layer tool for analyzing key price levels, designed mainly for intraday traders. The indicator combines levels derived from previous-day, previous-week and previous-month structure with volatility-based levels, the previous-day range, and automatic Sweep and Breakout detection.
The main idea is to gather the most important reference levels in one consistent tool. PDH/PDL, PWH/PWL and PMH/PML make it possible to watch significant historical highs and lows, while ATR levels mark an approximate expected range relative to the day open. In addition, the Day/Session Open and the PDH–PDL range divisions help assess where price currently sits inside the structure of the day.
One of the most important parts of the indicator is automatic Sweep and Breakout signaling. A Sweep identifies a situation in which price violates a key level and then closes back on the opposite side, pointing to a potential rejection of that level. A Breakout identifies a situation in which price breaks the level and holds the close on the breakout side, pointing to a potential continuation.
The indicator is built so that its appearance can be adapted almost completely to a given strategy. Each group of levels can be enabled independently and styled by color, line style, width and transparency. The user can also control how much history is kept on the chart, label placement, the length of extra range-division segments, and how current values are displayed.
As a result, the tool can be used either as a minimal map of key levels or as a richer contextual panel for intraday analysis.
█ CONCEPTS
Key Levels
Key Levels form the foundation of the indicator. They include Previous Day High/Low (PDH/PDL), Previous Week High/Low (PWH/PWL) and Previous Month High/Low (PMH/PML).
These levels represent the previous day, week and month and can act as potential support, resistance and reaction points. The higher the reference timeframe, the broader the context that level provides.
Day / Session Open
Day/Session Open shows the opening price of the current day or session.
This level can be used as a simple reference for judging where price is developing. Price holding above or below the open can add extra context when assessing the direction of the session.
ATR Levels
ATR Levels plot two lines relative to the day open — one above and one below.
Their distance is defined by ATR and a chosen multiplier, so the levels stay linked to current market volatility. They provide an approximate expected range that can be used as an extra reference in intraday analysis.
Previous Day Range
Previous Day Range highlights the area between PDH and PDL as a visually marked zone.
The range can be shown as a two-color split or as a gradient. This makes it easier to see which part of yesterday’s range price is currently in, and how it relates to the upper and lower boundaries of that area.
Range Division Levels
Range Division Levels split the PDH–PDL range at selected percentage values.
The default 25%, 50% and 75% levels create extra reference points inside the previous day’s range, but these values can be changed freely. The levels are drawn as short segments to the right of the last candle, so they do not clutter the main price structure.
Sweep
A Sweep represents a potential rejection of a key level.
The setup is armed when a candle’s wick violates the level. The indicator then waits for confirmation inside a defined bar window. The confirming close must occur on a later candle, not on the same candle that made the breach. For example, after PDH is pierced, price must then close back below that level on a bearish candle (close below open) to produce a Sweep Sell. Likewise, a pierce of PDL followed by a close back above the level on a bullish candle (close above open) can produce a Sweep Buy.
Breakout
A Breakout represents a potential hold on the breakout side and continuation of the move.
After the level is violated, the indicator waits for the next confirmation. If price closes on the breakout side, the confirming candle closes in the direction of the move, and the distance filter is met, a Breakout signal is generated. The same mechanism is used for daily, ATR, weekly and monthly levels.
Confirmation & Distance Filter
Signals are not generated from a single touch or wick through the level. The indicator uses a confirmation window and an optional minimum-distance filter for the confirming close, expressed as a multiple of ATR.
This helps reduce weaker signals in which price only slightly crosses the level without a clear confirming move.
If the confirmation window expires without a valid close, or after a Breakout is printed, the setup is locked until price reclaims the level. Only then can a new Sweep or Breakout setup start.
Distance-from-Levels Table
The Distance-from-Levels table shows the current distance of price from the main levels.
For each level it displays the price value and the distance in ATR units and in percent. This makes it possible to see quickly how close price is to key levels without measuring distances on the chart by hand.
█ FEATURES
Day / Week / Month Levels
• PDH / PDL – previous day’s High and Low
• PWH / PWL – previous week’s High and Low
• PMH / PML – previous month’s High and Low
• Each group can be turned on or off independently and has its own visual settings
• Color, line style, width and transparency can be used to build a visual hierarchy of levels on the chart
ATR Levels
• ATR High / Low plotted from the Day/Session Open
• Configurable ATR length, timeframe and distance multiplier
• Independent visibility and style controls
• ATR used for these levels is taken from closed bars of the selected timeframe and is fixed at the start of the day
Day / Session Open
• Current day or session opening price
• Configurable color, style, width and transparency
• Can be used as an extra reference for session direction
Previous Day Range
• Visualisation of the full range between PDH and PDL
• Two-Color or Gradient fill mode
• Independent colors and transparency for the upper and lower parts of the range
• Two-Color mode keeps a limited history of range boxes. Gradient mode is drawn as a fill between the current previous-day high and low
Range Division Levels
• Up to three configurable percentage levels inside the PDH–PDL range
• Any values from 0% to 100%
• Configurable segment length, horizontal offset, style and width
• Optional percentage labels
Sweep / Breakout Signals
• Sweep signals – potential rejection after a level is violated and price closes back on the opposite side
• Breakout signals – potential continuation after price holds the close on the breakout side
• Signals can be enabled independently for daily, ATR, weekly and monthly levels
• Configurable confirmation window in number of bars
• The piercing candle itself never generates a signal from its own close. Confirmation is evaluated from the next bar through the last bar of the window
• The confirming candle must also close in the signal direction: close below open for sell-side signals, close above open for buy-side signals
• Optional ATR-based minimum distance filter for the confirming close
• Independent Buy / Sell signal colors
• Sweeps are marked with diamonds, Breakouts with triangles
Labels & Live Price
• Global switch for all labels
• Adjustable size and horizontal offset for day, ATR, week and month label groups
• Optional live price labels at the right end of active lines
• Configurable decimal precision and offset from the last candle
History
• Independent number of stored daily, weekly and monthly levels
• Older lines, labels and range boxes are removed automatically to keep the chart readable
Day / Week / Month Reset
• Reset aligned with the instrument session
• Alternatively a manually defined reset time
• Time zone can be set for the manual reset
• Week and month boundaries follow the same reset method as the day
Distance-from-Levels Table
• Current value of each level
• Distance from price in xATR and %
• Configurable table position, text size and value precision
• Optional coloring of levels depending on whether they sit above price (resistance) or below price (support), using the Sell / Buy colors from the Sweep section
• Table ATR is always calculated on the current chart timeframe
Alerts
• Separate alerts for Sweep and Breakout on each individual level
• Combined alerts for any Sweep Buy / Sell and any Breakout Buy / Sell
• Can be used in TradingView alert automation
█ APPLICATIONS
Identifying key intraday reaction levels
The indicator can be used to mark in advance the levels where price may show increased activity. PDH, PDL, PWH, PWL, PMH and PML build a map of important historical levels, while ATR Levels add extra reference points derived from current volatility.
Trading a Sweep
Example scenario: price approaches PDH. Instead of assuming an automatic reversal, the trader watches the reaction. If price violates PDH, then returns below the level and a confirmed Sweep Sell appears, this may indicate that the breakout was not held. In that case the trader can still review market structure, momentum and trend before taking a trade.
Trading a Breakout
Alternative scenario: price tests PDH and breaks above it. If a later close holds on the breakout side, the confirming candle is in the direction of the move, and the distance filter is met, the indicator prints a Breakout Buy. The trader may then treat the level as potential confirmation of continuation and look for an entry in the direction of the breakout.
Combining Levels with Trend
Levels do not have to be treated as standalone trade signals. They can be combined with trend analysis. For example, in an uptrend a trader may prefer reactions at PDL or breakouts above PDH, while in a downtrend more attention may be given to reactions at PDH and breaks below PDL.
Using the Previous Day Range
The PDH–PDL range can serve as a map of the previous day’s internal structure. The trader can observe whether price is in the upper, middle or lower part of the range, then use the 25%, 50% and 75% levels as extra reference points when planning scenarios.
Using the Distance Table
The distance table can be used to see quickly which key level is closest to current price. This reduces the need to inspect many lines by hand and helps judge whether price is near a potential reaction level.
█ NOTES
• Signals require confirmation on a later candle after the bar that pierced the level. The piercing candle never triggers a signal from its own close.
• The confirming close must also be in the signal direction (close below open for sell-side Sweep/Breakout, close above open for buy-side Sweep/Breakout).
• The ATR distance filter can require the confirming close to be a chosen number of ATRs away from the violated level, which may help filter weaker confirmations. A filter value of 0 disables the distance requirement.
• If no valid confirmation appears inside the window, or after a Breakout is confirmed, a new setup on that level can start only after price reclaims the level.
• All main visual elements can be configured individually, so the indicator can be adapted both to a minimal chart and to a more detailed intraday workflow.
• Signals are best used as part of a broader analysis that includes market structure, trend, price action, support and resistance, and proper risk management.
Key Level Sweep & Breakout is a multi-layer tool for analyzing key price levels, designed mainly for intraday traders. The indicator combines levels derived from previous-day, previous-week and previous-month structure with volatility-based levels, the previous-day range, and automatic Sweep and Breakout detection.
The main idea is to gather the most important reference levels in one consistent tool. PDH/PDL, PWH/PWL and PMH/PML make it possible to watch significant historical highs and lows, while ATR levels mark an approximate expected range relative to the day open. In addition, the Day/Session Open and the PDH–PDL range divisions help assess where price currently sits inside the structure of the day.
One of the most important parts of the indicator is automatic Sweep and Breakout signaling. A Sweep identifies a situation in which price violates a key level and then closes back on the opposite side, pointing to a potential rejection of that level. A Breakout identifies a situation in which price breaks the level and holds the close on the breakout side, pointing to a potential continuation.
The indicator is built so that its appearance can be adapted almost completely to a given strategy. Each group of levels can be enabled independently and styled by color, line style, width and transparency. The user can also control how much history is kept on the chart, label placement, the length of extra range-division segments, and how current values are displayed.
As a result, the tool can be used either as a minimal map of key levels or as a richer contextual panel for intraday analysis.
█ CONCEPTS
Key Levels
Key Levels form the foundation of the indicator. They include Previous Day High/Low (PDH/PDL), Previous Week High/Low (PWH/PWL) and Previous Month High/Low (PMH/PML).
These levels represent the previous day, week and month and can act as potential support, resistance and reaction points. The higher the reference timeframe, the broader the context that level provides.
Day / Session Open
Day/Session Open shows the opening price of the current day or session.
This level can be used as a simple reference for judging where price is developing. Price holding above or below the open can add extra context when assessing the direction of the session.
ATR Levels
ATR Levels plot two lines relative to the day open — one above and one below.
Their distance is defined by ATR and a chosen multiplier, so the levels stay linked to current market volatility. They provide an approximate expected range that can be used as an extra reference in intraday analysis.
Previous Day Range
Previous Day Range highlights the area between PDH and PDL as a visually marked zone.
The range can be shown as a two-color split or as a gradient. This makes it easier to see which part of yesterday’s range price is currently in, and how it relates to the upper and lower boundaries of that area.
Range Division Levels
Range Division Levels split the PDH–PDL range at selected percentage values.
The default 25%, 50% and 75% levels create extra reference points inside the previous day’s range, but these values can be changed freely. The levels are drawn as short segments to the right of the last candle, so they do not clutter the main price structure.
Sweep
A Sweep represents a potential rejection of a key level.
The setup is armed when a candle’s wick violates the level. The indicator then waits for confirmation inside a defined bar window. The confirming close must occur on a later candle, not on the same candle that made the breach. For example, after PDH is pierced, price must then close back below that level on a bearish candle (close below open) to produce a Sweep Sell. Likewise, a pierce of PDL followed by a close back above the level on a bullish candle (close above open) can produce a Sweep Buy.
Breakout
A Breakout represents a potential hold on the breakout side and continuation of the move.
After the level is violated, the indicator waits for the next confirmation. If price closes on the breakout side, the confirming candle closes in the direction of the move, and the distance filter is met, a Breakout signal is generated. The same mechanism is used for daily, ATR, weekly and monthly levels.
Confirmation & Distance Filter
Signals are not generated from a single touch or wick through the level. The indicator uses a confirmation window and an optional minimum-distance filter for the confirming close, expressed as a multiple of ATR.
This helps reduce weaker signals in which price only slightly crosses the level without a clear confirming move.
If the confirmation window expires without a valid close, or after a Breakout is printed, the setup is locked until price reclaims the level. Only then can a new Sweep or Breakout setup start.
Distance-from-Levels Table
The Distance-from-Levels table shows the current distance of price from the main levels.
For each level it displays the price value and the distance in ATR units and in percent. This makes it possible to see quickly how close price is to key levels without measuring distances on the chart by hand.
█ FEATURES
Day / Week / Month Levels
• PDH / PDL – previous day’s High and Low
• PWH / PWL – previous week’s High and Low
• PMH / PML – previous month’s High and Low
• Each group can be turned on or off independently and has its own visual settings
• Color, line style, width and transparency can be used to build a visual hierarchy of levels on the chart
ATR Levels
• ATR High / Low plotted from the Day/Session Open
• Configurable ATR length, timeframe and distance multiplier
• Independent visibility and style controls
• ATR used for these levels is taken from closed bars of the selected timeframe and is fixed at the start of the day
Day / Session Open
• Current day or session opening price
• Configurable color, style, width and transparency
• Can be used as an extra reference for session direction
Previous Day Range
• Visualisation of the full range between PDH and PDL
• Two-Color or Gradient fill mode
• Independent colors and transparency for the upper and lower parts of the range
• Two-Color mode keeps a limited history of range boxes. Gradient mode is drawn as a fill between the current previous-day high and low
Range Division Levels
• Up to three configurable percentage levels inside the PDH–PDL range
• Any values from 0% to 100%
• Configurable segment length, horizontal offset, style and width
• Optional percentage labels
Sweep / Breakout Signals
• Sweep signals – potential rejection after a level is violated and price closes back on the opposite side
• Breakout signals – potential continuation after price holds the close on the breakout side
• Signals can be enabled independently for daily, ATR, weekly and monthly levels
• Configurable confirmation window in number of bars
• The piercing candle itself never generates a signal from its own close. Confirmation is evaluated from the next bar through the last bar of the window
• The confirming candle must also close in the signal direction: close below open for sell-side signals, close above open for buy-side signals
• Optional ATR-based minimum distance filter for the confirming close
• Independent Buy / Sell signal colors
• Sweeps are marked with diamonds, Breakouts with triangles
Labels & Live Price
• Global switch for all labels
• Adjustable size and horizontal offset for day, ATR, week and month label groups
• Optional live price labels at the right end of active lines
• Configurable decimal precision and offset from the last candle
History
• Independent number of stored daily, weekly and monthly levels
• Older lines, labels and range boxes are removed automatically to keep the chart readable
Day / Week / Month Reset
• Reset aligned with the instrument session
• Alternatively a manually defined reset time
• Time zone can be set for the manual reset
• Week and month boundaries follow the same reset method as the day
Distance-from-Levels Table
• Current value of each level
• Distance from price in xATR and %
• Configurable table position, text size and value precision
• Optional coloring of levels depending on whether they sit above price (resistance) or below price (support), using the Sell / Buy colors from the Sweep section
• Table ATR is always calculated on the current chart timeframe
Alerts
• Separate alerts for Sweep and Breakout on each individual level
• Combined alerts for any Sweep Buy / Sell and any Breakout Buy / Sell
• Can be used in TradingView alert automation
█ APPLICATIONS
Identifying key intraday reaction levels
The indicator can be used to mark in advance the levels where price may show increased activity. PDH, PDL, PWH, PWL, PMH and PML build a map of important historical levels, while ATR Levels add extra reference points derived from current volatility.
Trading a Sweep
Example scenario: price approaches PDH. Instead of assuming an automatic reversal, the trader watches the reaction. If price violates PDH, then returns below the level and a confirmed Sweep Sell appears, this may indicate that the breakout was not held. In that case the trader can still review market structure, momentum and trend before taking a trade.
Trading a Breakout
Alternative scenario: price tests PDH and breaks above it. If a later close holds on the breakout side, the confirming candle is in the direction of the move, and the distance filter is met, the indicator prints a Breakout Buy. The trader may then treat the level as potential confirmation of continuation and look for an entry in the direction of the breakout.
Combining Levels with Trend
Levels do not have to be treated as standalone trade signals. They can be combined with trend analysis. For example, in an uptrend a trader may prefer reactions at PDL or breakouts above PDH, while in a downtrend more attention may be given to reactions at PDH and breaks below PDL.
Using the Previous Day Range
The PDH–PDL range can serve as a map of the previous day’s internal structure. The trader can observe whether price is in the upper, middle or lower part of the range, then use the 25%, 50% and 75% levels as extra reference points when planning scenarios.
Using the Distance Table
The distance table can be used to see quickly which key level is closest to current price. This reduces the need to inspect many lines by hand and helps judge whether price is near a potential reaction level.
█ NOTES
• Signals require confirmation on a later candle after the bar that pierced the level. The piercing candle never triggers a signal from its own close.
• The confirming close must also be in the signal direction (close below open for sell-side Sweep/Breakout, close above open for buy-side Sweep/Breakout).
• The ATR distance filter can require the confirming close to be a chosen number of ATRs away from the violated level, which may help filter weaker confirmations. A filter value of 0 disables the distance requirement.
• If no valid confirmation appears inside the window, or after a Breakout is confirmed, a new setup on that level can start only after price reclaims the level.
• All main visual elements can be configured individually, so the indicator can be adapted both to a minimal chart and to a more detailed intraday workflow.
• Signals are best used as part of a broader analysis that includes market structure, trend, price action, support and resistance, and proper risk management.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。