Nonlinear Regression, Zero-lag Moving Average
May 23, 2023

The Nonlinear Regression, Zero-lag Moving Average indicator combines a non-linear curve-fitting algorithm with a lag-reduction moving average to provide a highly responsive trend-following tool.
Usage
The Usage section describes how the script can be used to identify market trends and potential reversal points. By merging two mathematical models, the indicator filters market noise while maintaining close proximity to price action.
- Trend Identification: The primary plot changes color based on the relationship between the current regression value and its previous state. A green line indicates an upward trend, while a red line indicates a downward trend.
- Crossover Signals: The tool generates "L" (Long) and "S" (Short) labels when the nonlinear regression line crosses above or below its previous value (signal line). These serve as entry or exit triggers in a trending market.
- Bar Coloring: Users can enable bar coloring to visually align the price action with the indicator’s current trend bias.
Details
The indicator is constructed using a two-step processing pipeline:
- Zero-lag Moving Average (ZLMA): The input source is first processed by a ZLMA. This calculation uses a double Linear Weighted Moving Average (LWMA) approach. By applying a decreasing weight scheme to the data and then re-applying it to the result, the indicator significantly reduces the lag typically found in standard moving averages.
- Nonlinear Regression: The smoothed ZLMA output is then passed through a nonlinear regression function. This function uses the least squares method to fit a curve to the data points by minimizing the sum of squared errors. This allows the indicator to adapt to non-linear price movements more accurately than a standard linear regression line.
The final output is a smoothed, reactive curve that anticipates trend shifts faster than traditional lagging indicators.
Settings
Basic Settings
- Source: Determines the price data used for calculations (e.g., Close, Open, HL2).
- Zero-lag Moving Average Period: Sets the lookback period for the ZLMA smoothing component.
- Nonlinear Regression Period: Sets the lookback period for the curve-fitting algorithm.
UI Options
- Color bars: Toggles whether the chart bars are colored based on the current trend direction.
- Show signals: Enables or disables the visual "L" and "S" shapes on the chart.
FAQ
How do I interpret the green and red colors? The green color indicates that the nonlinear regression value is higher than the previous period's value, suggesting bullish momentum. Red indicates the value is lower, suggesting bearish momentum.
What makes this different from a standard Moving Average? Unlike standard moving averages that lag behind price, this tool uses a zero-lag calculation combined with nonlinear curve fitting to stay closer to current price action while maintaining smoothness.
How can I access this indicator? 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.