Oreal | Consolidation Breakout Retest v1.0

Oreal | Consolidation Breakout Retest
OVERVIEW
This indicator identifies rule-based consolidation ranges on the active chart timeframe, draws their boundaries as boxes, and tracks a defined sequence:
Consolidation confirmed -> qualifying body breakout -> optional later retest.
BREAKOUT labels distinguish upward and downward closing breaks. RETEST labels identify a subsequent candle that revisits the broken boundary and closes back on the breakout side while satisfying the selected filters.
A breakout does not require a retest to occur. If price does not return, the script does not create a retest label.
IMPLEMENTATION AND PRACTICAL VALUE
The implementation combines three range-qualification checks: volatility-relative width, low directional efficiency, and repeated candle contact near both edges. Once a range is recognized, its price boundaries are fixed.
The event logic then separates the first closing exit from a later retest. An exit that fails the breakout requirements consumes the range without receiving a BREAKOUT label, preventing a later candle from being presented as its original breakout.
The practical contribution is this coordinated range and event lifecycle. Consolidation, ATR, breakouts and retests are established concepts; their use is not a claim of a new market principle or predictive accuracy.
HOW CONSOLIDATION IS IDENTIFIED
The default candidate window contains 12 closed chart candles. Its upper boundary is the highest high in the window, and its lower boundary is the lowest low, including wicks.
A candidate must satisfy all of these default conditions:
- Box height is at least four minimum price ticks.
- Box height is no greater than 3.0 times ATR(14), sampled from the candle immediately before the candidate window begins.
- Directional efficiency is no greater than 0.35.
- At least two candles reach the upper edge band, and at least two reach the lower edge band. Each band extends inward by 15% of the box height.
Directional efficiency is calculated as:
Absolute change between the first and last closes in the window / Sum of absolute consecutive closing-price changes within that window.
A lower value represents less net directional progress relative to the path traveled. If that closing-price path is zero, the efficiency value is treated as zero.
Edge contacts count qualifying candles. Consecutive candles can count separately; these are not necessarily independent swing tests.
The range becomes known only when the qualifying window has closed. Its box is then drawn back over that window for context. The historical left edge must not be interpreted as an earlier-available signal.
LOCKED RANGE BEHAVIOR
After confirmation, the box's high and low remain fixed. Its right edge extends while the range is active, but a wick outside the box does not widen its price boundaries or create a breakout label.
An unbroken range expires 120 candles after detection by default, unless a qualifying breakout is processed on that candle.
BODY BREAKOUT RULES
With the default settings, an upward breakout requires:
- A close at least one tick above the upper boundary.
- A nonzero candle body representing at least 50% of the candle's full high-low range.
- At least 25% of that body lying above the upper boundary.
- A bullish candle body: close above open.
A downward breakout applies the equivalent conditions below the lower boundary and requires a bearish body by default.
The closing buffer, minimum body size, outside-body percentage and candle-direction requirement are configurable. Setting the outside-body percentage to 100 requires the entire body to lie beyond the boundary.
The first close beyond a boundary by the configured buffer ends the range. If that exit fails the selected filters, or occurs in a disabled direction, the box becomes inactive without a BREAKOUT label. It is not kept available for another breakout attempt.
RETEST RULES
After a qualifying breakout, the script waits for a later candle. The breakout candle itself cannot also receive a RETEST label.
By default, the next 20 chart candles are eligible. A retest requires:
- Candle-range overlap with the broken boundary's tolerance band, set to four ticks on either side by default.
- A close at least one tick beyond the boundary in the breakout direction.
- A nonzero body representing at least 20% of the retest candle's full range.
- A matching candle direction: bullish after an upward breakout, bearish after a downward breakout.
The tolerance, waiting window, minimum retest body and direction requirement are adjustable.
A close back inside the box beyond the tolerance cancels the waiting sequence. The sequence also ends when the waiting window expires or its first qualifying retest is confirmed. A later revisit does not reactivate that completed sequence.
DISPLAY AND SEQUENCE MANAGEMENT
The default display uses a blue range box, green upward BREAKOUT labels, red downward BREAKOUT labels and cyan RETEST labels. Colors, fill transparency and text size are configurable.
The chart timeframe can be shown inside each box and event label. An optional dashed line tracks the broken boundary while waiting for a retest. A compact panel displays the current state and last event.
Native candle colors are preserved.
Only one sequence is active at a time. While a range or retest sequence is active, the script does not open another active box. After the sequence ends, a fresh candidate must contain a full window of candles formed after that ending bar.
Eight recent sequences are retained by default, with an adjustable retention limit.
TIMEFRAMES AND DATA
All calculations use the active chart's OHLC candles. There are no higher-timeframe or lower-timeframe requests, volume filters, footprint requirements or cross-market comparisons.
The indicator is intended for standard time-based OHLC charts, including intraday, daily, weekly and monthly intervals, with sufficient available history. Changing timeframe recalculates the ranges from that timeframe's candles.
Settings expressed in bars represent different elapsed durations on different timeframes. The defaults are starting parameters, not settings proven optimal for every instrument or interval.
ALERTS
Four alert conditions are available:
- Upward body breakout.
- Downward body breakout.
- Upward retest confirmed.
- Downward retest confirmed.
These events are evaluated on confirmed candle closes. Select Once Per Bar Close when creating a TradingView alert. Recreate alerts after changing settings if the alerts should use the new configuration.
HOW TO USE
1. Select a standard chart and the timeframe you want to analyze.
2. Adjust the candidate length, width limit and edge-contact requirements to suit the intended range definition.
3. Review confirmed boxes separately from their later event labels.
4. Use BREAKOUT to identify a qualifying closed-body exit.
5. Wait for a separate RETEST label if a confirmed boundary revisit is part of your process.
6. Apply your own broader market context and risk rules.
LIMITATIONS
Consolidation is defined by the stated mathematical conditions. The script will not identify every range a trader might draw manually, and some qualifying boxes may form within a broader trend.
Breakouts and retests can fail. A RETEST label confirms the programmed candle conditions, not a profitable entry or guaranteed continuation.
Confirmed events require candle closure, which introduces delay. Box anchors are displayed historically after recognition; only horizontal drawing extensions move intrabar. Recalculating with different settings, chart intervals or available history can change the displayed sequences.
The indicator does not identify institutional orders, place trades, calculate stop losses or targets, or provide a backtested performance report.
OVERVIEW
This indicator identifies rule-based consolidation ranges on the active chart timeframe, draws their boundaries as boxes, and tracks a defined sequence:
Consolidation confirmed -> qualifying body breakout -> optional later retest.
BREAKOUT labels distinguish upward and downward closing breaks. RETEST labels identify a subsequent candle that revisits the broken boundary and closes back on the breakout side while satisfying the selected filters.
A breakout does not require a retest to occur. If price does not return, the script does not create a retest label.
IMPLEMENTATION AND PRACTICAL VALUE
The implementation combines three range-qualification checks: volatility-relative width, low directional efficiency, and repeated candle contact near both edges. Once a range is recognized, its price boundaries are fixed.
The event logic then separates the first closing exit from a later retest. An exit that fails the breakout requirements consumes the range without receiving a BREAKOUT label, preventing a later candle from being presented as its original breakout.
The practical contribution is this coordinated range and event lifecycle. Consolidation, ATR, breakouts and retests are established concepts; their use is not a claim of a new market principle or predictive accuracy.
HOW CONSOLIDATION IS IDENTIFIED
The default candidate window contains 12 closed chart candles. Its upper boundary is the highest high in the window, and its lower boundary is the lowest low, including wicks.
A candidate must satisfy all of these default conditions:
- Box height is at least four minimum price ticks.
- Box height is no greater than 3.0 times ATR(14), sampled from the candle immediately before the candidate window begins.
- Directional efficiency is no greater than 0.35.
- At least two candles reach the upper edge band, and at least two reach the lower edge band. Each band extends inward by 15% of the box height.
Directional efficiency is calculated as:
Absolute change between the first and last closes in the window / Sum of absolute consecutive closing-price changes within that window.
A lower value represents less net directional progress relative to the path traveled. If that closing-price path is zero, the efficiency value is treated as zero.
Edge contacts count qualifying candles. Consecutive candles can count separately; these are not necessarily independent swing tests.
The range becomes known only when the qualifying window has closed. Its box is then drawn back over that window for context. The historical left edge must not be interpreted as an earlier-available signal.
LOCKED RANGE BEHAVIOR
After confirmation, the box's high and low remain fixed. Its right edge extends while the range is active, but a wick outside the box does not widen its price boundaries or create a breakout label.
An unbroken range expires 120 candles after detection by default, unless a qualifying breakout is processed on that candle.
BODY BREAKOUT RULES
With the default settings, an upward breakout requires:
- A close at least one tick above the upper boundary.
- A nonzero candle body representing at least 50% of the candle's full high-low range.
- At least 25% of that body lying above the upper boundary.
- A bullish candle body: close above open.
A downward breakout applies the equivalent conditions below the lower boundary and requires a bearish body by default.
The closing buffer, minimum body size, outside-body percentage and candle-direction requirement are configurable. Setting the outside-body percentage to 100 requires the entire body to lie beyond the boundary.
The first close beyond a boundary by the configured buffer ends the range. If that exit fails the selected filters, or occurs in a disabled direction, the box becomes inactive without a BREAKOUT label. It is not kept available for another breakout attempt.
RETEST RULES
After a qualifying breakout, the script waits for a later candle. The breakout candle itself cannot also receive a RETEST label.
By default, the next 20 chart candles are eligible. A retest requires:
- Candle-range overlap with the broken boundary's tolerance band, set to four ticks on either side by default.
- A close at least one tick beyond the boundary in the breakout direction.
- A nonzero body representing at least 20% of the retest candle's full range.
- A matching candle direction: bullish after an upward breakout, bearish after a downward breakout.
The tolerance, waiting window, minimum retest body and direction requirement are adjustable.
A close back inside the box beyond the tolerance cancels the waiting sequence. The sequence also ends when the waiting window expires or its first qualifying retest is confirmed. A later revisit does not reactivate that completed sequence.
DISPLAY AND SEQUENCE MANAGEMENT
The default display uses a blue range box, green upward BREAKOUT labels, red downward BREAKOUT labels and cyan RETEST labels. Colors, fill transparency and text size are configurable.
The chart timeframe can be shown inside each box and event label. An optional dashed line tracks the broken boundary while waiting for a retest. A compact panel displays the current state and last event.
Native candle colors are preserved.
Only one sequence is active at a time. While a range or retest sequence is active, the script does not open another active box. After the sequence ends, a fresh candidate must contain a full window of candles formed after that ending bar.
Eight recent sequences are retained by default, with an adjustable retention limit.
TIMEFRAMES AND DATA
All calculations use the active chart's OHLC candles. There are no higher-timeframe or lower-timeframe requests, volume filters, footprint requirements or cross-market comparisons.
The indicator is intended for standard time-based OHLC charts, including intraday, daily, weekly and monthly intervals, with sufficient available history. Changing timeframe recalculates the ranges from that timeframe's candles.
Settings expressed in bars represent different elapsed durations on different timeframes. The defaults are starting parameters, not settings proven optimal for every instrument or interval.
ALERTS
Four alert conditions are available:
- Upward body breakout.
- Downward body breakout.
- Upward retest confirmed.
- Downward retest confirmed.
These events are evaluated on confirmed candle closes. Select Once Per Bar Close when creating a TradingView alert. Recreate alerts after changing settings if the alerts should use the new configuration.
HOW TO USE
1. Select a standard chart and the timeframe you want to analyze.
2. Adjust the candidate length, width limit and edge-contact requirements to suit the intended range definition.
3. Review confirmed boxes separately from their later event labels.
4. Use BREAKOUT to identify a qualifying closed-body exit.
5. Wait for a separate RETEST label if a confirmed boundary revisit is part of your process.
6. Apply your own broader market context and risk rules.
LIMITATIONS
Consolidation is defined by the stated mathematical conditions. The script will not identify every range a trader might draw manually, and some qualifying boxes may form within a broader trend.
Breakouts and retests can fail. A RETEST label confirms the programmed candle conditions, not a profitable entry or guaranteed continuation.
Confirmed events require candle closure, which introduces delay. Box anchors are displayed historically after recognition; only horizontal drawing extensions move intrabar. Recalculating with different settings, chart intervals or available history can change the displayed sequences.
The indicator does not identify institutional orders, place trades, calculate stop losses or targets, or provide a backtested performance report.
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。