OPEN-SOURCE SCRIPT
Range Breakout [sgbpulse]

Range Breakout [sgbpulse]
1. Overview
The "Range Breakout [sgbpulse]" indicator is a powerful tool designed to identify and visually display price ranges on your chart using pivot points. It dynamically draws two distinct boxes – an External Range and an Internal Range – helping traders pinpoint potential support and resistance zones. Beyond its visual representation, the indicator offers a comprehensive set of 12 unique breakout alerts, providing real-time notifications for significant price movements outside these defined ranges. Additionally, it integrates RSI and MFI metrics for momentum confirmation.
2. How It Works
The indicator operates by identifying pivot points based on user-defined "left" and "right" bar lengths. A high pivot is a bar with a specified number of lower highs both to its left and right, and similarly for a low pivot.
The External Range will always be greater than or equal to the Internal Range, as it's based on a wider historical context. Both ranges are displayed as transparent boxes on your chart, dynamically adjusting as new pivots are formed.
3. Key Features and Settings
Customizable Pivot Lengths:
Customizable Range Colors: Easily change the background colors of the External and Internal Range boxes to match your chart's aesthetic.
Dynamic Range Display: The indicator automatically updates the range boxes as new pivot highs and lows are formed, always presenting the most current valid ranges.
RSI / MFI Settings:
4. Synergy of Ranges & Breakout Strength
The interaction between the External and Internal Ranges provides deep insights into price movement and breakout strength:
5. Visuals
The indicator provides clear visual representations on the chart:
Range Boxes:
RSI/MFI Status Labels:
Plotting of Key Values:
6. Comprehensive Breakout Alerts
The "Range Breakout [sgbpulse]" indicator provides 12 distinct alert conditions for breakouts, allowing you to select the required level of confirmation for each alert. All alerts are triggered only upon a fully confirmed bar close (barstate.isconfirmed) to minimize false signals and ensure reliability.
All breakout alerts are configured to detect a Crossover/Crossunder of the levels, meaning a specific event where the price moves from one side of the range to the other.
7. Ideal Use Cases
This indicator is ideal for traders who:
8. Complementary Indicator
For even more comprehensive market analysis, we highly recommend using this indicator in conjunction with Market Structure Support & Resistance External/Internal & BoS [sgbpulse].
This powerful complementary indicator automatically and accurately identifies significant support and resistance levels by locating high and low pivot points, as well as key Pre-Market High/Low levels. Its strength lies in its dynamic adaptability to any timeframe and asset, providing precise and relevant real-time levels while maintaining a clean chart. It also identifies Break of Structure (BoS) to signal potential trend changes or continuations.
Using both indicators together provides a robust framework for identifying defined ranges and potential trend shifts, enabling more informed trading decisions.
View Market Structure Support & Resistance External/Internal & BoS [sgbpulse] Indicator
9. Important Note: Trading Risk
This indicator is intended for educational and informational purposes only and does not constitute investment advice or a recommendation for trading in any form whatsoever.
Trading in financial markets involves significant risk of capital loss. It is important to remember that past performance is not indicative of future results. All trading decisions are your sole responsibility. Never trade with money you cannot afford to lose.
1. Overview
The "Range Breakout [sgbpulse]" indicator is a powerful tool designed to identify and visually display price ranges on your chart using pivot points. It dynamically draws two distinct boxes – an External Range and an Internal Range – helping traders pinpoint potential support and resistance zones. Beyond its visual representation, the indicator offers a comprehensive set of 12 unique breakout alerts, providing real-time notifications for significant price movements outside these defined ranges. Additionally, it integrates RSI and MFI metrics for momentum confirmation.
2. How It Works
The indicator operates by identifying pivot points based on user-defined "left" and "right" bar lengths. A high pivot is a bar with a specified number of lower highs both to its left and right, and similarly for a low pivot.
- External Range: Calculated using longer pivot lengths (default: 15 bars left, 6 bars right). This range represents broader, more significant price consolidation areas.
- Internal Range: Calculated using shorter pivot lengths (default: 4 bars left, 3 bars right). This range captures tighter, more immediate price consolidations within the broader trend.
The External Range will always be greater than or equal to the Internal Range, as it's based on a wider historical context. Both ranges are displayed as transparent boxes on your chart, dynamically adjusting as new pivots are formed.
3. Key Features and Settings
Customizable Pivot Lengths:
- External Range (Left/Right Bars): Adjust sensitivity for identifying the broader price range. Longer lengths lead to more stable, but less frequent, range updates.
- Internal Range (Left/Right Bars): Adjust sensitivity for the tighter, more immediate price range.
- Tool Tips: Minimum 6 bars for the External Range, and minimum 2 bars for the Internal Range.
Customizable Range Colors: Easily change the background colors of the External and Internal Range boxes to match your chart's aesthetic.
Dynamic Range Display: The indicator automatically updates the range boxes as new pivot highs and lows are formed, always presenting the most current valid ranges.
RSI / MFI Settings:
- Timeframe Source: Select the timeframe for RSI and MFI calculation.
- Chart: Calculation based on the current chart timeframe.
- Daily: Always calculated based on the daily ("D") timeframe, even if the chart is on a lower timeframe. - RSI Length: Period length for RSI calculation (default: 14).
- RSI Overbought Level: Overbought level for RSI (default: 70.0).
- RSI Oversold Level: Oversold level for RSI (default: 30.0).
- MFI Length: Period length for MFI calculation (default: 14).
- MFI Overbought Level: Overbought level for MFI (default: 80.0).
- MFI Oversold Level: Oversold level for MFI (default: 20.0).
4. Synergy of Ranges & Breakout Strength
The interaction between the External and Internal Ranges provides deep insights into price movement and breakout strength:
- Immediate Direction: The movement of the Internal Range (up or down) indicates the short-term directional bias within the broader framework of the External Range.
- Strength Confirmation: A breakout of the External Range, followed by a breakout of the Internal Range, confirms the strength of the move and increases confidence in the breakout.
- Strong Momentum ("Leaving" Ranges Behind): When price breaks out with exceptionally strong momentum, it continues to move aggressively and does not immediately form new pivots. In such situations, the existing ranges (External and Internal) remain in place while the candles "leave them behind." A "Full Candle" breakout, where the entire candle moves past both ranges, indicates a particularly powerful and decisive move.
- Momentum (RSI / MFI) as Confirmation:
- RSI (Relative Strength Index): Measures the speed and change of price movements. Extreme values (above 70 or below 30) indicate overbought/oversold conditions respectively, confirming strong momentum in a breakout.
- MFI (Money Flow Index): Similar to RSI but incorporates volume. Extreme values (above 80 or below 20) indicate strong money flow in/out, reinforcing breakout confirmation.
- Importance of Confirmation: If a breakout occurs but momentum indicators do not confirm it (for example, an upside breakout while RSI is declining), this could signal weakness in the move and the risk of a false breakout (Fakeout).
5. Visuals
The indicator provides clear visual representations on the chart:
Range Boxes:
- Two dynamic boxes are drawn on the chart: one for the External Range and one for the Internal Range.
- These boxes update continuously, displaying the current range boundaries based on the latest pivots. They provide an immediate visual indication of support and resistance levels.
RSI/MFI Status Labels:
- Small text labels appear to the right of the current bar, vertically centered.
- They display the status of RSI and MFI: RSI OB (Overbought), RSI OS (Oversold), MFI OB, MFI OS, along with the exact value.
- Important: The labels remain on the chart as long as the condition holds (indicator is above/below the level), unlike alerts which mark a singular crossover event.
Plotting of Key Values:
- The indicator plots six invisible series on the chart, primarily to allow the user to view the exact numerical values of:
- The upper and lower bounds of the External Range (External High, External Low).
- The upper and lower bounds of the Internal Range (Internal High, Internal Low).
- The calculated RSI and MFI values (RSI, MFI). - These values are accessible for viewing through TradingView's Data Window and also via the Status Line when hovering over the relevant candle. This enables more precise quantitative analysis of range levels and momentum.
6. Comprehensive Breakout Alerts
The "Range Breakout [sgbpulse]" indicator provides 12 distinct alert conditions for breakouts, allowing you to select the required level of confirmation for each alert. All alerts are triggered only upon a fully confirmed bar close (barstate.isconfirmed) to minimize false signals and ensure reliability.
All breakout alerts are configured to detect a Crossover/Crossunder of the levels, meaning a specific event where the price moves from one side of the range to the other.
- External Range Breakout UP
- Close: Price closes above the External Range.
- Real Body: The entire "real body" of the candle (min of open/close prices) closes above the External Range.
- Full Candle: The entire candle (the lowest point of the candle) closes above the External Range. - External Range Breakout DOWN
- Close: Price closes below the External Range.
- Real Body: The entire "real body" of the candle (max of open/close prices) closes below the External Range.
- Full Candle: The entire candle (the highest point of the candle) closes below the External Range. - Internal Range Breakout UP
- Close: Price closes above the Internal Range.
- Real Body: The "real body" of the candle closes above the Internal Range.
- Full Candle: The entire candle closes above the Internal Range. - Internal Range Breakout DOWN
- Close: Price closes below the Internal Range.
- Real Body: The "real body" of the candle closes below the Internal Range.
- Full Candle: The entire candle closes below the Internal Range.
7. Ideal Use Cases
This indicator is ideal for traders who:
- Want to clearly identify and monitor price consolidation zones.
- Seek confirmation for breakout strategies across various timeframes.
- Require reliable and automated alerts for potential entry or exit points based on range expansion.
8. Complementary Indicator
For even more comprehensive market analysis, we highly recommend using this indicator in conjunction with Market Structure Support & Resistance External/Internal & BoS [sgbpulse].
This powerful complementary indicator automatically and accurately identifies significant support and resistance levels by locating high and low pivot points, as well as key Pre-Market High/Low levels. Its strength lies in its dynamic adaptability to any timeframe and asset, providing precise and relevant real-time levels while maintaining a clean chart. It also identifies Break of Structure (BoS) to signal potential trend changes or continuations.
Using both indicators together provides a robust framework for identifying defined ranges and potential trend shifts, enabling more informed trading decisions.
View Market Structure Support & Resistance External/Internal & BoS [sgbpulse] Indicator
9. Important Note: Trading Risk
This indicator is intended for educational and informational purposes only and does not constitute investment advice or a recommendation for trading in any form whatsoever.
Trading in financial markets involves significant risk of capital loss. It is important to remember that past performance is not indicative of future results. All trading decisions are your sole responsibility. Never trade with money you cannot afford to lose.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.