Linear Regression (LINREG)
period
= 14 (2–200) Overview
The Linear Regression indicator represents a powerful statistical approach to technical analysis, plotting the ending value of a regression line that best fits recent price data. Unlike moving averages that simply average past prices, LINREG calculates where price should statistically be based on the underlying trend, making it significantly more responsive to trend changes. This mathematical precision comes from applying least squares regression analysis to price data, creating a line that minimizes the sum of squared distances between actual prices and the fitted line. The result is an indicator that acts like a "smart" moving average, anticipating price movements rather than merely following them.
What makes LINREG particularly valuable is its dual nature as both a trend-following tool and a forecasting indicator. The slope of the regression line reveals trend strength and direction - steeper slopes indicate stronger trends, while flattening slopes warn of potential reversals. More importantly, LINREG projects where price is expected to be based on statistical probability, allowing traders to identify when price has deviated too far from its expected path. This characteristic makes it excellent for mean reversion strategies, as prices tend to oscillate around the regression line. When combined with channel bands based on standard deviation or ATR, LINREG becomes a complete trading system that identifies trends, forecasts price targets, and highlights overbought/oversold conditions.
Interpretation & Trading Signals
Trend Analysis:
- Rising LINREG: Uptrend confirmed, expect higher prices
- Falling LINREG: Downtrend confirmed, expect lower prices
- Flat LINREG: No trend, ranging market conditions
- Slope Changes: Early warning of trend reversals
Trading Strategies:
- Trend Following: Buy when price crosses above rising LINREG
- Mean Reversion: Trade back toward LINREG from extremes
- Channel Trading: Buy at lower channel, sell at upper channel
- Breakout Trading: Trade channel breaks in trend direction
Risk Management:
- Stop Placement: Use LINREG as dynamic stop level
- Position Sizing: Larger positions when price near LINREG
- Exit Strategy: Take profits at statistical extremes
- Confirmation: Combine with momentum indicators
Example Usage
Code examples will be available once the Rust implementation is complete.
Performance Analysis
Related Indicators
Pivot Moving Average
Technical analysis indicator
Variable Index Dynamic Average
Technical analysis indicator
Variable Length Moving Average
Technical analysis indicator
Arnaud Legoux Moving Average
Moving average indicator
Centered Weighted Moving Average
Moving average indicator
Double Exponential Moving Average
Moving average indicator