Charts
Linear Regression Slope R2 (R2)
Linear regression is a statistical tool used
to help predict future values from past values. It is commonly used
as a quantitative way to determine the underlying trend and when
prices are overextended. A linear regression trendline uses the
least squares method to plot a straight line through prices so as
to minimize the distances between the prices and the resulting trendline.
This linear regression indicator plots the slope of the trendline
value for each given data point.
Configuration Options
- Period: Number of bars to use in the calculations.
- Field: Price or combination of prices to use as the base for average calculations. Possible values include:
- Open
- High
- Low
- Close
- Adjusted Close
- HL/2 \( \left ( \frac{High + Low}{2} \right ) \)
- HLC/3 \( \left ( \frac{High + Low + Close}{3} \right ) \)
- HLCC/4 \( \left ( \frac{High + Low + Close + Close}{4} \right ) \)
- OHLC/4 \( \left ( \frac{Open + High + Low + Close}{4} \right ) \)
- Color Selectors: Colors to use for graph elements.
- Display Axis Label: Whether to display the most recent value on the Y axis.
Formula
The best fit line associated with the n points
(x1, y1), (x2, y2), . . . , (x_{n}, y_{n}) has the
form y = mx + b
\[LR R^2 = \frac{SS_{Regression}}{SS_{Total}} \]
where:
- SS_{Regression} = sum of the squared difference between each fitted value of Y on
the regression line and the mean of Y. This shows the variation in the fitted values
of Y while drawing a fitted regression line.
- SS_{Total} = sum of the squared difference between each value of Y and the mean
of Y. This shows the variation in the values of Y.