Linear Regression Candles
Mar 10, 2021

The Linear Regression Candles indicator transforms traditional price bars into smoothed candle shapes based on linear regression, providing a clearer view of trend direction and potential reversals.
Usage
The Usage section describes how the script can be used to identify market trends and momentum shifts. By applying linear regression to the individual components of a candle (Open, High, Low, and Close), the indicator filters out market noise and presents a more fluid representation of price action.
- Trend Identification: Users can observe the color of the candles to determine the current trend. Green candles indicate a bullish regression trend, while red candles indicate a bearish trend.
- Signal Line Crossovers: The indicator includes a signal line that acts as a baseline for the smoothed price. When the linear regression candles cross above or below this signal line, it can signify a change in market momentum or a potential entry/exit point.
- Price Smoothing: Traders can adjust the Linear Regression Length to increase or decrease the smoothing effect, allowing the script to be tailored for either scalping or long-term trend following.
Details
The Linear Regression Candles indicator is based on the original code by @ugurvu and has been refactored for modern performance. Unlike standard linear regression lines or channels, this script calculates the ta.linreg value for the Open, High, Low, and Close prices independently over a specific lookback period.
The resulting values are then plotted using the plotcandle function to create a synthetic chart that overlays the real price action. The signal line is calculated by applying a moving average (either SMA or EMA) to the smoothed Close value of the regression candles, providing a secondary layer of trend confirmation.
Settings
- Signal Smoothing: Determines the lookback period used to calculate the signal line.
- Simple MA (Signal Line): When enabled, the signal line uses a Simple Moving Average (SMA). When disabled, it uses an Exponential Moving Average (EMA).
- Lin Reg: A toggle to enable or disable the linear regression calculation for the candles.
- Linear Regression Length: Sets the lookback window for the linear regression calculation; higher values result in smoother candles but increased lag.
FAQ
How do the candles differ from standard price candles? Standard candles show raw market data, whereas Linear Regression Candles show the statistically "expected" price based on a linear trend over the selected length, making it easier to see the underlying trend without minor price fluctuations.
What does a crossover of the signal line indicate? A crossover typically indicates a shift in momentum. If the regression candles move above the signal line, it suggests bullish momentum is building, while a move below suggests bearish momentum.
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.