RSI Trendlines and Divergences
Oct 2, 2025

The RSI Trendlines and Divergences indicator provides an advanced technical analysis framework by automatically drawing trendlines on the Relative Strength Index (RSI) and detecting price/oscillator divergences. It identifies key pivot points to reveal potential trend reversals and breakout opportunities across all asset classes and timeframes.
Usage
This tool is used to identify shifts in momentum that may not be immediately visible on the price chart. Users can monitor trendline breakouts on the RSI to anticipate price reversals.
- Trendline Breakouts: When the RSI crosses above a descending red trendline, it signals a bullish breakout. Conversely, when the RSI crosses below an ascending green trendline, it signals a bearish breakout.
- Divergence Signals: The script identifies "Bull" and "Bear" divergences. A bullish divergence occurs when price makes a lower low but the RSI makes a higher low. A bearish divergence occurs when price makes a higher high but the RSI makes a lower high.
- Tolerance Zones: The indicator uses a "Tolerance" setting to create a visual fill around trendlines. Breakouts are only confirmed once the RSI exits this zone, which helps filter out market noise and false signals.
Details
The indicator constructs trendlines by connecting RSI pivot points. Upper trendlines connect lower highs (downtrends), while lower trendlines connect higher lows (uptrends).
- Calculation: RSI is calculated using a standard period (default 14). Pivots are determined based on a "look-back" and "look-forward" period to ensure the structural integrity of the trendline.
- Extension: Trendlines are extended by a user-defined number of bars after the second pivot point to provide future areas of interest.
- Confirmation: Breakout signals are highlighted via background coloring (Green for bullish, Red for bearish) for immediate visual confirmation.
Settings
RSI Settings
- RSI Length: The look-back period for the Relative Strength Index calculation.
- SMA Length: The period for the moving average applied to the RSI.
- Source: The price data used for calculation (e.g., Close, Open, High).
Pivot Settings for Trend
- Left Bars for Pivot: Number of bars to the left required to identify a pivot.
- Right Bars for Pivot: Number of bars to the right required to confirm a pivot.
- Extension after Second Pivot: How many bars the trendline extends into the future.
- Tolerance: The width (in RSI points) of the margin around the trendline used to validate breakouts.
Divergence Settings
- Enable Divergence Detection: Toggles the display of Bullish and Bearish divergence labels.
- Pivot Length for Divergence: The period used to detect pivots specifically for divergence logic.
Style Settings
- Colors/Transparency: Customizable options for trendlines, fills, moving averages, and background signal highlights.
FAQ
How do I access RSI Trendlines and Divergences?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Why do the divergence labels appear with a delay?
Divergence labels rely on pivot confirmation. This requires a "Right Bars" or "Pivot Length" period to pass to ensure the high or low point is actually a pivot, making the signals non-repainting but slightly delayed.
Can I use this for automated alerts?
Yes, the indicator includes built-in alert conditions for bullish/bearish divergences and trendline breakouts, which can be configured via the TradingView alert menu.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.