OPEN-SOURCE SCRIPT
byquan RSI Divergence (OB/OS + RSI MA Base)

byquan RSI Divergence (OB/OS + RSI MA Base)
Description
byquan RSI Divergence is a technical analysis indicator designed to visualize RSI-based divergence patterns within clearly defined overbought and oversold zones, enhanced with an optional RSI moving average baseline.
The script focuses on structural divergence detection rather than signal prediction, providing visual reference points to help users study momentum behavior and price–oscillator relationships.
This indicator is intended for educational and analytical purposes only.
Conceptual Overview
The core idea of this indicator is based on a widely accepted technical principle:
When price structure and momentum structure diverge, market behavior may be transitioning rather than continuing impulsively.
Instead of reacting to every fluctuation, this script identifies well-defined divergence formations that occur:
At RSI pivot points
Within controlled lookback ranges
Inside overbought or oversold zones
Indicator Components
1. RSI Oscillator
The indicator uses a standard Relative Strength Index (RSI):
User-defined period
User-defined source price
RSI values are plotted directly in the pane for transparency and clarity.
2. RSI Base Moving Average
An optional RSI baseline is calculated using a selectable moving average type:
SMA
EMA
RMA
WMA
This baseline is intended to provide additional context for momentum direction and smoothing, not as a signal trigger.
3. Overbought / Oversold Zones
Customizable horizontal levels define:
Overbought conditions
Oversold conditions
Divergences are evaluated only when RSI is located inside the corresponding zone, helping reduce irrelevant signals.
4. Pivot-Based Divergence Detection
The script detects RSI pivot highs and lows using configurable left/right lookback values.
Based on these pivots, it evaluates four divergence types:
Regular Bullish Divergence
Hidden Bullish Divergence
Regular Bearish Divergence
Hidden Bearish Divergence
Each divergence type is plotted independently and can be enabled or disabled by the user.
5. Lookback Range Control
To avoid excessive or outdated comparisons, divergence evaluation is constrained within a user-defined bar range.
This helps ensure that only structurally relevant divergences are displayed.
Visualization
Divergence lines are plotted directly on the RSI pane
Labels are used to distinguish divergence types
Regular and hidden divergences are visually differentiated using color transparency
The indicator prioritizes clarity and interpretability over signal density.
Alert Logic
An alert condition is provided when any divergence type is detected.
Alerts are informational and do not imply direction, timing, or outcome.
Intended Use
This indicator is designed to be used as:
A momentum structure study tool
A visual divergence reference
A supporting component within broader technical analysis
It is not intended to:
Predict market tops or bottoms
Serve as a standalone trading system
Provide financial or investment advice
Technical Notes
The script uses pivot-based confirmation and therefore does not repaint
All calculations are deterministic and rule-based
Divergences are identified only after pivots are confirmed
Results may vary across assets and timeframes
Attribution & Transparency
This script represents a custom implementation and adaptation of commonly documented RSI divergence techniques, including:
Pivot-based divergence logic
Overbought / oversold filtering
RSI smoothing via moving averages
These concepts are widely used in technical analysis.
The specific parameterization, visualization, and filtering structure reflect a personal analytical approach, without claiming exclusivity over the underlying methods.
Disclaimer
This indicator is provided for educational and analytical purposes only.
It does not constitute financial advice, trading recommendations, or performance guarantees.
Past behavior does not imply future results.
Description
byquan RSI Divergence is a technical analysis indicator designed to visualize RSI-based divergence patterns within clearly defined overbought and oversold zones, enhanced with an optional RSI moving average baseline.
The script focuses on structural divergence detection rather than signal prediction, providing visual reference points to help users study momentum behavior and price–oscillator relationships.
This indicator is intended for educational and analytical purposes only.
Conceptual Overview
The core idea of this indicator is based on a widely accepted technical principle:
When price structure and momentum structure diverge, market behavior may be transitioning rather than continuing impulsively.
Instead of reacting to every fluctuation, this script identifies well-defined divergence formations that occur:
At RSI pivot points
Within controlled lookback ranges
Inside overbought or oversold zones
Indicator Components
1. RSI Oscillator
The indicator uses a standard Relative Strength Index (RSI):
User-defined period
User-defined source price
RSI values are plotted directly in the pane for transparency and clarity.
2. RSI Base Moving Average
An optional RSI baseline is calculated using a selectable moving average type:
SMA
EMA
RMA
WMA
This baseline is intended to provide additional context for momentum direction and smoothing, not as a signal trigger.
3. Overbought / Oversold Zones
Customizable horizontal levels define:
Overbought conditions
Oversold conditions
Divergences are evaluated only when RSI is located inside the corresponding zone, helping reduce irrelevant signals.
4. Pivot-Based Divergence Detection
The script detects RSI pivot highs and lows using configurable left/right lookback values.
Based on these pivots, it evaluates four divergence types:
Regular Bullish Divergence
Hidden Bullish Divergence
Regular Bearish Divergence
Hidden Bearish Divergence
Each divergence type is plotted independently and can be enabled or disabled by the user.
5. Lookback Range Control
To avoid excessive or outdated comparisons, divergence evaluation is constrained within a user-defined bar range.
This helps ensure that only structurally relevant divergences are displayed.
Visualization
Divergence lines are plotted directly on the RSI pane
Labels are used to distinguish divergence types
Regular and hidden divergences are visually differentiated using color transparency
The indicator prioritizes clarity and interpretability over signal density.
Alert Logic
An alert condition is provided when any divergence type is detected.
Alerts are informational and do not imply direction, timing, or outcome.
Intended Use
This indicator is designed to be used as:
A momentum structure study tool
A visual divergence reference
A supporting component within broader technical analysis
It is not intended to:
Predict market tops or bottoms
Serve as a standalone trading system
Provide financial or investment advice
Technical Notes
The script uses pivot-based confirmation and therefore does not repaint
All calculations are deterministic and rule-based
Divergences are identified only after pivots are confirmed
Results may vary across assets and timeframes
Attribution & Transparency
This script represents a custom implementation and adaptation of commonly documented RSI divergence techniques, including:
Pivot-based divergence logic
Overbought / oversold filtering
RSI smoothing via moving averages
These concepts are widely used in technical analysis.
The specific parameterization, visualization, and filtering structure reflect a personal analytical approach, without claiming exclusivity over the underlying methods.
Disclaimer
This indicator is provided for educational and analytical purposes only.
It does not constitute financial advice, trading recommendations, or performance guarantees.
Past behavior does not imply future results.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.