OPEN-SOURCE SCRIPT
RSI Pivots with Divergence Overlay

█ OVERVIEW
The RSI Pivots with Divergence Overlay indicator is an advanced tool based on RSI, displaying dynamic bands on the price chart to simplify the identification of overbought and oversold conditions. Pivot points and divergences between them are derived from these bands, providing a comprehensive view of the market and enabling the creation of various trading strategies based on this single indicator.
█ CONCEPTS
Areas where RSI exits the bands are often reversal points in the market. The concept of this indicator is to highlight places where the probability of a trend reversal increases. Therefore, pivots and divergences have been added to better identify these key moments. Additionally, the bands allow viewing the market context in relation to the RSI indicator, facilitating analysis of momentum and volatility.
█ KEY FEATURES
Dynamic Bands and RSI Signals: The bands are calculated based on the closing price and RSI value, with dynamic scaling adjusted to market volatility. The upper band corresponds to overbought levels, the lower to oversold, and the midline is their average. The price level relative to the bands serves as a visual RSI signal, indicating potential overbought or oversold conditions.
Pivot Points: The indicator identifies local price highs and lows in relation to RSI levels. The pivot level is taken from the high/low of the candle. A high pivot is detected when the high of the candle reaches a local maximum after crossing the upper RSI level (overbought), signaling a potential reversal. A low pivot appears after a local price minimum following a drop below the lower RSI level (oversold), indicating a possible uptrend reversal. The pivot length (default 2 bars) defines the search range for these extremes, meaning that with a length of 2, a potential divergence signal will appear with a 2-candle delay, as this is the minimum time required to confirm a local pivot. Pivot lines are drawn on the chart, and labels display the RSI value (from the close of the candle) and price at the detection moment. Pivot lines disappear after the detection of the next low pivot for lower lines and high pivot for upper lines, but unbreached lines or those with high volume may still serve as support or resistance levels.
Divergence Detection: The indicator automatically detects divergences to predict trend changes. Bearish divergence occurs when the price forms a higher high pivot, but the RSI (from the close of the candle) is lower than in the previous pivot, indicating weakening upward momentum and a potential bearish reversal. Bullish divergence appears when the price forms a lower low pivot, but the RSI is higher, suggesting building momentum and a possible bullish reversal. Divergences are marked in pivot labels (e.g., "Bear Div" or "Bull Div") and supported by alerts upon detection.
Return Signals: The indicator generates buy and sell signals based on RSI (price) returning to the bands after extreme conditions, independently of pivots and divergences. A buy signal is triggered when RSI (price) crosses above the lower level (exiting oversold), suggesting a potential price rise toward the midline or upper band. A sell signal occurs when RSI (price) falls below the upper level (exiting overbought), indicating a possible price drop toward the lower band. Signals are visualized as arrows (up/down triangles) on the chart, with customizable colors.
█ CONFIGURATION
The indicator offers extensive customization options:
RSI Length (rsiLength): Sets the number of periods used to calculate RSI (default 14).
RSI Upper Level (rsiUpper): Defines the overbought threshold (default 70).
RSI Lower Level (rsiLower): Defines the oversold threshold (default 30).
Band Scaling (scale): Determines the scaling multiplier for bands based on market volatility (default 15.0).
SMA Length for Candle Midpoint (length): Number of periods for calculating the moving average of candle midpoints (default 200). This parameter is used to smooth price data, enabling more accurate volatility assessment and band width adjustment to market dynamics.
Pivot Length (pivotLength): Sets the range (in bars) for detecting local price extremes (default 2).
Pivot Label Offset (pivotLabelOffset): Multiplier for the candle range to position pivot labels (default 0.3).
Show Bands (showBands): Enables/disables the display of bands on the chart.
Show Fill (showFill): Enables/disables the fill between bands and the midline.
Show Pivot Lines (showPivotLines): Enables/disables pivot lines on the chart.
Show Pivot Labels (showPivotLabels): Enables/disables labels with RSI and price values at pivots.
Show Return Signals (showReturnSignals): Enables/disables the display of buy and sell signals.
Colors and Style: Customizable colors for bands, fills, pivot lines, labels, and line widths (default 1).
█ USAGE
The indicator performs best when combined with other technical analysis tools, such as Fibonacci levels, moving averages, or trendlines, to confirm pivot, divergence, and return signals. It enables traders to identify key reversal points, detect hidden trend weaknesses through divergences, and confirm trade entries with return signals.
Usage Examples:
Price bounces off a previous pivot with high volume – this increases the probability of a trend change or correction.
A similar situation when RSI is outside the bands strengthens the signal.
If divergence occurs in addition, we have further confirmation.
This can be combined with Fibonacci levels to check if Fibo zones overlap with pivot lines – this may increase the chance of a strong price reaction.
█ ALERTS
The indicator supports alerts for:
Buy and sell signals (RSI returning to bands).
Detection of bearish and bullish divergences.
The RSI Pivots with Divergence Overlay indicator is an advanced tool based on RSI, displaying dynamic bands on the price chart to simplify the identification of overbought and oversold conditions. Pivot points and divergences between them are derived from these bands, providing a comprehensive view of the market and enabling the creation of various trading strategies based on this single indicator.
█ CONCEPTS
Areas where RSI exits the bands are often reversal points in the market. The concept of this indicator is to highlight places where the probability of a trend reversal increases. Therefore, pivots and divergences have been added to better identify these key moments. Additionally, the bands allow viewing the market context in relation to the RSI indicator, facilitating analysis of momentum and volatility.
█ KEY FEATURES
Dynamic Bands and RSI Signals: The bands are calculated based on the closing price and RSI value, with dynamic scaling adjusted to market volatility. The upper band corresponds to overbought levels, the lower to oversold, and the midline is their average. The price level relative to the bands serves as a visual RSI signal, indicating potential overbought or oversold conditions.
Pivot Points: The indicator identifies local price highs and lows in relation to RSI levels. The pivot level is taken from the high/low of the candle. A high pivot is detected when the high of the candle reaches a local maximum after crossing the upper RSI level (overbought), signaling a potential reversal. A low pivot appears after a local price minimum following a drop below the lower RSI level (oversold), indicating a possible uptrend reversal. The pivot length (default 2 bars) defines the search range for these extremes, meaning that with a length of 2, a potential divergence signal will appear with a 2-candle delay, as this is the minimum time required to confirm a local pivot. Pivot lines are drawn on the chart, and labels display the RSI value (from the close of the candle) and price at the detection moment. Pivot lines disappear after the detection of the next low pivot for lower lines and high pivot for upper lines, but unbreached lines or those with high volume may still serve as support or resistance levels.
Divergence Detection: The indicator automatically detects divergences to predict trend changes. Bearish divergence occurs when the price forms a higher high pivot, but the RSI (from the close of the candle) is lower than in the previous pivot, indicating weakening upward momentum and a potential bearish reversal. Bullish divergence appears when the price forms a lower low pivot, but the RSI is higher, suggesting building momentum and a possible bullish reversal. Divergences are marked in pivot labels (e.g., "Bear Div" or "Bull Div") and supported by alerts upon detection.
Return Signals: The indicator generates buy and sell signals based on RSI (price) returning to the bands after extreme conditions, independently of pivots and divergences. A buy signal is triggered when RSI (price) crosses above the lower level (exiting oversold), suggesting a potential price rise toward the midline or upper band. A sell signal occurs when RSI (price) falls below the upper level (exiting overbought), indicating a possible price drop toward the lower band. Signals are visualized as arrows (up/down triangles) on the chart, with customizable colors.
█ CONFIGURATION
The indicator offers extensive customization options:
RSI Length (rsiLength): Sets the number of periods used to calculate RSI (default 14).
RSI Upper Level (rsiUpper): Defines the overbought threshold (default 70).
RSI Lower Level (rsiLower): Defines the oversold threshold (default 30).
Band Scaling (scale): Determines the scaling multiplier for bands based on market volatility (default 15.0).
SMA Length for Candle Midpoint (length): Number of periods for calculating the moving average of candle midpoints (default 200). This parameter is used to smooth price data, enabling more accurate volatility assessment and band width adjustment to market dynamics.
Pivot Length (pivotLength): Sets the range (in bars) for detecting local price extremes (default 2).
Pivot Label Offset (pivotLabelOffset): Multiplier for the candle range to position pivot labels (default 0.3).
Show Bands (showBands): Enables/disables the display of bands on the chart.
Show Fill (showFill): Enables/disables the fill between bands and the midline.
Show Pivot Lines (showPivotLines): Enables/disables pivot lines on the chart.
Show Pivot Labels (showPivotLabels): Enables/disables labels with RSI and price values at pivots.
Show Return Signals (showReturnSignals): Enables/disables the display of buy and sell signals.
Colors and Style: Customizable colors for bands, fills, pivot lines, labels, and line widths (default 1).
█ USAGE
The indicator performs best when combined with other technical analysis tools, such as Fibonacci levels, moving averages, or trendlines, to confirm pivot, divergence, and return signals. It enables traders to identify key reversal points, detect hidden trend weaknesses through divergences, and confirm trade entries with return signals.
Usage Examples:
Price bounces off a previous pivot with high volume – this increases the probability of a trend change or correction.
A similar situation when RSI is outside the bands strengthens the signal.
If divergence occurs in addition, we have further confirmation.
This can be combined with Fibonacci levels to check if Fibo zones overlap with pivot lines – this may increase the chance of a strong price reaction.
█ ALERTS
The indicator supports alerts for:
Buy and sell signals (RSI returning to bands).
Detection of bearish and bullish divergences.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.