OPEN-SOURCE SCRIPT
Breakout Retest Signals [algotim]

Overview
Breakout Retest Quality Signals is a price-structure indicator designed to distinguish ordinary level breaks from breakouts that produce a meaningful retest.
The script does not treat every cross of a swing level as a valid breakout. A confirmed swing high or low first establishes the structural reference. Price must then close beyond that level by a minimum ATR-adjusted distance. Once the breakout qualifies, the script creates a volatility-scaled zone around the broken level and monitors the following price action for a retest.
The central purpose of the indicator is to evaluate the quality of that retest rather than simply marking every touch of the broken level.
Problem Statement
A basic breakout indicator can produce signals whenever price moves marginally above or below a previous high or low. Likewise, a basic retest indicator may treat any return to the broken level as confirmation.
Those approaches do not distinguish between a decisive breakout followed by a controlled rejection and a weak breakout followed by deep penetration of the level.
This script addresses that problem by separating the setup into three stages:
**structural breakout -> volatility-scaled retest zone -> retest quality evaluation**
This makes the retest itself part of the signal validation process.
Methodology
1. Confirmed structural levels
The script uses confirmed pivot highs and pivot lows to establish the most recent structural reference points.
A pivot is confirmed using the configured swing length, so the structural levels are not based on unconfirmed turning points.
2. ATR-qualified breakout
A bullish breakout occurs when price crosses above the most recent confirmed pivot high.
A bearish breakout occurs when price crosses below the most recent confirmed pivot low.
The breakout must also exceed the configured minimum breakout strength, measured as a multiple of ATR:
**Bullish displacement = close - broken high**
**Bearish displacement = broken low - close**
The displacement must be at least the user-defined ATR multiple.
This prevents small crosses around a structural level from automatically becoming breakout events.
3. Dynamic breakout zone
After a qualified breakout, the script creates a zone around the broken structural level.
The zone width is calculated from ATR rather than from a fixed number of ticks or points:
**Zone width = ATR x Zone Width Multiplier**
This allows the same methodology to account for different volatility conditions.
For a bullish breakout, the broken level becomes a potential support area.
For a bearish breakout, the broken level becomes a potential resistance area.
4. Retest monitoring
After the breakout, the zone remains active while the script waits for price to return to it.
The retest is only considered during the configured retest window. The zone also has a maximum lifetime so that an old breakout does not remain active indefinitely.
This creates an explicit state sequence rather than evaluating every bar independently:
**Breakout detected -> zone active -> retest pending -> retest evaluated -> confirmed or invalidated**
5. Retest Quality Engine
The primary differentiating component is the Retest Quality Engine.
When price enters the breakout zone, the script measures how deeply price penetrates the zone before moving back in the breakout direction.
Penetration is normalized against the width of the zone, allowing the measurement to remain related to the current volatility regime.
The resulting quality score favors relatively shallow and decisive rejection while assigning lower quality to deeper penetration.
The score is then compared with the user-defined minimum quality threshold.
This means that touching the zone alone is not necessarily enough to generate a signal.
6. Rejection confirmation
When the rejection-candle option is enabled, the retest must also close back outside the zone in the original breakout direction.
For a bullish setup, price must reject the zone and close back above it.
For a bearish setup, price must reject the zone and close back below it.
This additional condition separates a retest rejection from a simple penetration of the breakout area.
Signal Workflow
Bullish workflow
1. A confirmed pivot high establishes a structural resistance level.
2. Price crosses above that pivot.
3. The close must exceed the pivot by at least the configured ATR displacement.
4. A bullish breakout zone is created around the broken level.
5. The script waits for price to return to that zone.
6. Penetration depth is measured relative to the zone width.
7. The Retest Quality Engine converts the penetration into a quality score.
8. If the score meets the minimum threshold, the retest can qualify.
9. When rejection-candle confirmation is enabled, price must close back above the zone.
10. A bullish confirmation is then displayed.
Bearish workflow
1. A confirmed pivot low establishes a structural support level.
2. Price crosses below that pivot.
3. The close must exceed the pivot by at least the configured ATR displacement.
4. A bearish breakout zone is created around the broken level.
5. The script waits for price to return to that zone.
6. Penetration depth is measured relative to the zone width.
7. The Retest Quality Engine calculates the retest quality.
8. If the score meets the minimum threshold, the retest can qualify.
9. When rejection-candle confirmation is enabled, price must close back below the zone.
10. A bearish confirmation is then displayed.
Why This Indicator Is Different
A conventional breakout script generally answers one question:
**Did price break the level?**
A conventional retest script generally adds:
**Did price come back to the level?**
This indicator adds another layer:
**How cleanly did price reject the breakout zone after returning to it?**
The distinction is important because not all retests have the same structure.
The implementation combines the breakout and retest stages into one state-based process. ATR is used in two separate but related ways: first to filter weak structural breaks, and then to scale the breakout zone to current volatility.
The Retest Quality Engine then evaluates the interaction with that zone rather than treating every retest as equivalent.
The result is a more selective breakout-retest workflow instead of a collection of unrelated indicators.
Inputs
Structure Detection
**Swing Lookback (Pivot Length)**
Controls the number of bars used to confirm swing highs and lows.
**Minimum Breakout Strength (x ATR)**
Sets the minimum closing displacement beyond the structural level required for a breakout.
Breakout Zone
**Zone Width (x ATR)**
Controls the width of the dynamic breakout zone.
**Zone Max Lifetime (bars)**
Limits how long a breakout zone remains active.
Retest and Quality Engine
**Max Bars to Wait for Retest**
Defines the maximum number of bars allowed between breakout and retest.
**Minimum Retest Quality Score**
Sets the minimum quality score required for confirmation.
**Require Rejection Candle on Retest**
Requires the retest candle to close back in the breakout direction.
Volatility
**ATR Length**
Controls the ATR calculation used for breakout displacement and zone sizing.
Visual Style
The visual settings control bullish and bearish colors, zone opacity, confirmation labels, and the number of active zones displayed.
Alerts
The script can be used with TradingView alerts for the available confirmation conditions.
Alerts should be configured from the script's available alert conditions after adding the indicator to the chart.
Practical Usage
The indicator is intended to be used as a structural price-action filter.
A practical workflow is to first identify the direction and broader market context, then use the script to monitor qualified structural breaks and their subsequent retests.
Higher minimum breakout-strength and retest-quality settings will generally make the conditions more selective.
Lower thresholds will allow more setups but may also admit weaker breakouts and less decisive retests.
The breakout zone can also be used as a visual reference for evaluating whether price is accepting or rejecting the broken structure.
Signals should be evaluated together with the instrument, timeframe, market conditions, and the trader's own risk-management process.
Limitations
Pivot levels require confirmation and therefore are identified only after the required swing bars have formed.
A breakout that satisfies the ATR threshold does not guarantee continuation.
The quality score measures the geometry of the retest relative to the calculated zone; it does not predict the future direction or magnitude of price movement.
ATR-based measurements adapt to volatility but do not eliminate market noise.
A retest can fail after confirmation, particularly during rapidly changing or range-bound conditions.
The indicator is an analytical tool and should not be interpreted as a guarantee of profitable trading results.
Notes
This script is based on a single price-structure workflow: confirm the structural level, qualify the breakout using ATR displacement, define a volatility-scaled zone, monitor the retest, and evaluate the quality of the rejection.
The intention is to provide a consistent framework for studying breakout-retest behavior rather than to claim that every qualified setup will produce continuation.
Breakout Retest Quality Signals is a price-structure indicator designed to distinguish ordinary level breaks from breakouts that produce a meaningful retest.
The script does not treat every cross of a swing level as a valid breakout. A confirmed swing high or low first establishes the structural reference. Price must then close beyond that level by a minimum ATR-adjusted distance. Once the breakout qualifies, the script creates a volatility-scaled zone around the broken level and monitors the following price action for a retest.
The central purpose of the indicator is to evaluate the quality of that retest rather than simply marking every touch of the broken level.
Problem Statement
A basic breakout indicator can produce signals whenever price moves marginally above or below a previous high or low. Likewise, a basic retest indicator may treat any return to the broken level as confirmation.
Those approaches do not distinguish between a decisive breakout followed by a controlled rejection and a weak breakout followed by deep penetration of the level.
This script addresses that problem by separating the setup into three stages:
**structural breakout -> volatility-scaled retest zone -> retest quality evaluation**
This makes the retest itself part of the signal validation process.
Methodology
1. Confirmed structural levels
The script uses confirmed pivot highs and pivot lows to establish the most recent structural reference points.
A pivot is confirmed using the configured swing length, so the structural levels are not based on unconfirmed turning points.
2. ATR-qualified breakout
A bullish breakout occurs when price crosses above the most recent confirmed pivot high.
A bearish breakout occurs when price crosses below the most recent confirmed pivot low.
The breakout must also exceed the configured minimum breakout strength, measured as a multiple of ATR:
**Bullish displacement = close - broken high**
**Bearish displacement = broken low - close**
The displacement must be at least the user-defined ATR multiple.
This prevents small crosses around a structural level from automatically becoming breakout events.
3. Dynamic breakout zone
After a qualified breakout, the script creates a zone around the broken structural level.
The zone width is calculated from ATR rather than from a fixed number of ticks or points:
**Zone width = ATR x Zone Width Multiplier**
This allows the same methodology to account for different volatility conditions.
For a bullish breakout, the broken level becomes a potential support area.
For a bearish breakout, the broken level becomes a potential resistance area.
4. Retest monitoring
After the breakout, the zone remains active while the script waits for price to return to it.
The retest is only considered during the configured retest window. The zone also has a maximum lifetime so that an old breakout does not remain active indefinitely.
This creates an explicit state sequence rather than evaluating every bar independently:
**Breakout detected -> zone active -> retest pending -> retest evaluated -> confirmed or invalidated**
5. Retest Quality Engine
The primary differentiating component is the Retest Quality Engine.
When price enters the breakout zone, the script measures how deeply price penetrates the zone before moving back in the breakout direction.
Penetration is normalized against the width of the zone, allowing the measurement to remain related to the current volatility regime.
The resulting quality score favors relatively shallow and decisive rejection while assigning lower quality to deeper penetration.
The score is then compared with the user-defined minimum quality threshold.
This means that touching the zone alone is not necessarily enough to generate a signal.
6. Rejection confirmation
When the rejection-candle option is enabled, the retest must also close back outside the zone in the original breakout direction.
For a bullish setup, price must reject the zone and close back above it.
For a bearish setup, price must reject the zone and close back below it.
This additional condition separates a retest rejection from a simple penetration of the breakout area.
Signal Workflow
Bullish workflow
1. A confirmed pivot high establishes a structural resistance level.
2. Price crosses above that pivot.
3. The close must exceed the pivot by at least the configured ATR displacement.
4. A bullish breakout zone is created around the broken level.
5. The script waits for price to return to that zone.
6. Penetration depth is measured relative to the zone width.
7. The Retest Quality Engine converts the penetration into a quality score.
8. If the score meets the minimum threshold, the retest can qualify.
9. When rejection-candle confirmation is enabled, price must close back above the zone.
10. A bullish confirmation is then displayed.
Bearish workflow
1. A confirmed pivot low establishes a structural support level.
2. Price crosses below that pivot.
3. The close must exceed the pivot by at least the configured ATR displacement.
4. A bearish breakout zone is created around the broken level.
5. The script waits for price to return to that zone.
6. Penetration depth is measured relative to the zone width.
7. The Retest Quality Engine calculates the retest quality.
8. If the score meets the minimum threshold, the retest can qualify.
9. When rejection-candle confirmation is enabled, price must close back below the zone.
10. A bearish confirmation is then displayed.
Why This Indicator Is Different
A conventional breakout script generally answers one question:
**Did price break the level?**
A conventional retest script generally adds:
**Did price come back to the level?**
This indicator adds another layer:
**How cleanly did price reject the breakout zone after returning to it?**
The distinction is important because not all retests have the same structure.
The implementation combines the breakout and retest stages into one state-based process. ATR is used in two separate but related ways: first to filter weak structural breaks, and then to scale the breakout zone to current volatility.
The Retest Quality Engine then evaluates the interaction with that zone rather than treating every retest as equivalent.
The result is a more selective breakout-retest workflow instead of a collection of unrelated indicators.
Inputs
Structure Detection
**Swing Lookback (Pivot Length)**
Controls the number of bars used to confirm swing highs and lows.
**Minimum Breakout Strength (x ATR)**
Sets the minimum closing displacement beyond the structural level required for a breakout.
Breakout Zone
**Zone Width (x ATR)**
Controls the width of the dynamic breakout zone.
**Zone Max Lifetime (bars)**
Limits how long a breakout zone remains active.
Retest and Quality Engine
**Max Bars to Wait for Retest**
Defines the maximum number of bars allowed between breakout and retest.
**Minimum Retest Quality Score**
Sets the minimum quality score required for confirmation.
**Require Rejection Candle on Retest**
Requires the retest candle to close back in the breakout direction.
Volatility
**ATR Length**
Controls the ATR calculation used for breakout displacement and zone sizing.
Visual Style
The visual settings control bullish and bearish colors, zone opacity, confirmation labels, and the number of active zones displayed.
Alerts
The script can be used with TradingView alerts for the available confirmation conditions.
Alerts should be configured from the script's available alert conditions after adding the indicator to the chart.
Practical Usage
The indicator is intended to be used as a structural price-action filter.
A practical workflow is to first identify the direction and broader market context, then use the script to monitor qualified structural breaks and their subsequent retests.
Higher minimum breakout-strength and retest-quality settings will generally make the conditions more selective.
Lower thresholds will allow more setups but may also admit weaker breakouts and less decisive retests.
The breakout zone can also be used as a visual reference for evaluating whether price is accepting or rejecting the broken structure.
Signals should be evaluated together with the instrument, timeframe, market conditions, and the trader's own risk-management process.
Limitations
Pivot levels require confirmation and therefore are identified only after the required swing bars have formed.
A breakout that satisfies the ATR threshold does not guarantee continuation.
The quality score measures the geometry of the retest relative to the calculated zone; it does not predict the future direction or magnitude of price movement.
ATR-based measurements adapt to volatility but do not eliminate market noise.
A retest can fail after confirmation, particularly during rapidly changing or range-bound conditions.
The indicator is an analytical tool and should not be interpreted as a guarantee of profitable trading results.
Notes
This script is based on a single price-structure workflow: confirm the structural level, qualify the breakout using ATR displacement, define a volatility-scaled zone, monitor the retest, and evaluate the quality of the rejection.
The intention is to provide a consistent framework for studying breakout-retest behavior rather than to claim that every qualified setup will produce continuation.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Build your trading tools with AI : algotim.com
All content provided by AlgoTim (algo_aakash) is for informational and educational purposes only. Trading involves risk, and past performance does not guarantee future results.
All content provided by AlgoTim (algo_aakash) is for informational and educational purposes only. Trading involves risk, and past performance does not guarantee future results.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Build your trading tools with AI : algotim.com
All content provided by AlgoTim (algo_aakash) is for informational and educational purposes only. Trading involves risk, and past performance does not guarantee future results.
All content provided by AlgoTim (algo_aakash) is for informational and educational purposes only. Trading involves risk, and past performance does not guarantee future results.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.