Trend Lines for RSI, CCI, Momentum, OBV
Mar 26, 2020

The Trend Lines for RSI, CCI, Momentum, OBV indicator automatically detects and draws trend lines on popular oscillators to highlight potential breakouts and trend shifts within momentum data.
Usage
The Usage section describes how the script can be used to identify trend continuation or reversals on momentum-based indicators. Traders can use these trend lines to spot divergences or breakout opportunities that may not be as apparent on the price chart itself.
- Trend Line Breakouts: When the selected indicator crosses above a descending trend line or below an ascending trend line, it often signals a shift in momentum that may precede price action.
- Support and Resistance: Trend lines drawn on oscillators like RSI or CCI can act as dynamic support and resistance levels for the indicator value.
- Multi-Indicator Analysis: Users can toggle between RSI, CCI, OBV, and Momentum to see which oscillator provides the cleanest trend structure for the current market environment.
Details
The script operates by identifying the most recent Pivot Points (PP) for the selected indicator. It stores the coordinates of the last 10 higher and lower pivots to evaluate potential trend line placements.
To ensure the trend lines are valid, the script performs the following logic:
- It calculates the slope between various pivot points.
- It iterates through the data points between pivots to ensure that the indicator value has not "broken" the line prematurely.
- If a valid, unbroken line is found, it is projected forward to the current bar.
- The script uses optimized loops and angle checks to maintain performance and stay within execution time limits.
Settings
- Indicator: Selects the base oscillator for trend line calculation (RSI, CCI, OBV, or Momentum).
- Source: Determines the price data used for the indicator calculations (default is Close).
- RSI Length: Sets the lookback period for the RSI calculation.
- CCI Length: Sets the lookback period for the CCI calculation.
- Momentum Length: Sets the lookback period for the Momentum calculation.
- Pivot Point Period: Defines the number of bars on either side of a point required to classify it as a Pivot High or Pivot Low.
- Number of Pivot Point to check: Determines how many historical pivots the script evaluates to find valid trend lines.
FAQ
How can I change which indicator the trend lines are drawn on? You can change the base indicator by opening the script settings and selecting your preferred option (RSI, CCI, OBV, or Momentum) from the "Indicator" dropdown menu.
Why does the script take a few seconds to load? Because the script performs complex historical calculations and iterative loops to ensure trend lines do not intersect the indicator data improperly, it may require a few seconds to initialize when first added to a chart.
How do I get access to Trend Lines for RSI, CCI, Momentum, OBV? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
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.