All indicators

RSI Linear Regression with ZigZag

Oct 17, 2021

Static chart image
SignalsOscillatorsChannelsPatterns

The RSI Linear Regression with ZigZag indicator combines momentum analysis with statistical trends to help traders identify market reversals and trend strength. By applying Linear Regression channels and ZigZag pivot logic directly to the Relative Strength Index (RSI), this tool provides a multi-layered approach to spotting overextended conditions and momentum shifts.

Usage

The Usage section focuses on interpreting the three core components of the script:

  • Linear Regression Channel: The central dotted line represents the mean momentum trend, while the upper and lower solid lines act as dynamic deviation bands. Prices breaking outside these bands often suggest overextended momentum.
  • ZigZag Labels: The indicator automatically identifies Higher Highs (HH), Lower Highs (LH), Higher Lows (HL), and Lower Lows (LL) on the RSI line. These labels are essential for identifying market structure shifts and potential divergence patterns against price action.
  • Correlation Metric: A label on the left side of the regression channel displays the correlation coefficient. A positive value (green) indicates an upward momentum trend, while a negative value (red) indicates a downward trend.

Details

This tool calculates a standard RSI and then applies a Linear Regression algorithm over a user-defined "Trend Period." It computes the slope and intercept to project a best-fit line through the RSI data. The deviation bands are calculated based on either a "Biased" or "Unbiased" estimator, allowing for statistical flexibility. The ZigZag component uses pivot high and pivot low logic to filter out minor RSI fluctuations, highlighting only the most significant momentum swings.

Settings

General

  • Length: The lookback period for the standard RSI calculation.
  • Source: The price data used for the RSI (typically "Close").
  • Trend Period: The number of bars used to calculate the Linear Regression channel.
  • Deviation: A multiplier for the standard deviation to determine the width of the regression bands.
  • Estimator: Choose between "Biased" or "Unbiased" statistical calculations for the deviation.
  • Extend: Determines if the regression lines extend to the right of the chart or remain as segments.
  • Zigzag Length: The period used to determine pivot points for identifying market structure labels (HH, LH, etc.).

FAQ

How do I use the RSI ZigZag for divergence?

You can compare the ZigZag labels (like Higher Highs) on the RSI to the actual price action. If the RSI makes a Lower High while price makes a Higher High, it indicates bearish divergence.

What does the correlation number mean?

The number represents how closely the RSI follows the linear trend. Values closer to 1 or -1 indicate a very strong linear momentum trend, while values near 0 suggest a non-trending or choppy RSI.

How can I access this script?

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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.