Calculation of Linear Regression R-Squared
The Linear regression statistical technique is used for calculating the value of
one dependent variable when one has the values of independent variable or variables
M. This is in the form of a straight line which “best fits” the data
points of prices available, using the least squares technique. The Linear Regression
R-Squared is derived by calculating ratio of the sum of squared difference between
the fitted values of the regression line and the mean, to the sum of squared difference
between each actual price value and the mean. This is an intense calculation process
as it involves calculation of regression lines and their R-Squared value at each
The Linear Regression R-Squared indicator is generally drawn as a line chart below
the price chart and not overlaid on the chart itself. In addition, this is usually
viewed along with other indicators such as the Linear Regression Slope indicator.
This is calculated as follows:
LR R2 = SS (Regression) / SS (Total)
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.
Another way to look at this is:
LR R2 = 1 – SS (Error) / SS (Total)
SS (Error) = SS (Total) – SS (Regression)
In effect, the Linear Regression R-Squared Indicator provides a confidence value
which tells us how well the linear regression line is fitting the data at that particular
bar. Thus a high value means that the linear regression line represents the price
data of the regression period very well. This is important because a corollary to
this is that the forecasted price of the stock at that point by the linear regression
line is likely to be quite correct (or fitting to the regression line). Therefore,
it offers a measure of the correctness of the predicted or forecasted value by the
As mentioned above the Linear Regression R-Squared indicator shows a confidence
value. The confidence value is determined by the R-Squared critical level and the
regression period used for the R-squared calculation. Typically a value of .70 or
more is considered to be high confidence level for shorter term regression periods
and .40 or more for medium term periods.
Typically the Linear Regression R-Squared is illustrated as a Line chart below the price chart. This is a banded oscillator between 0 and 1. It is usually accompanied with the Linear Regression Slope indicator or another momentum oscillator also drawn below the price chart.
Lengths and timeframes
Linear Regression R-Squared can be used as a leading indicator as it shows high
confidence value where the regression line has better fit and therefore market trend
is closer to the expected. It is used for measuring the trend strength or weakness
and confirming the momentum of the market. The lengths or timeframes used can change
depending on the trend being analysed. It can range from 5 days for a short term
trend, to 20 days for medium trend to 100 days for a long term trend. Used with
momentum indicators, it can highlight good entry and exit points for trading.
Trend identification / Crossovers
R-Squared is very valuable as a confirming indicator. Momentum indicators (for example
Stochastics, RSI, CCI, etc.) and moving average indicators need a validation of
trend in order to be reliably useful. R-squared offers a way of indicating the intensity
of the trend of prices.
As mentioned, R-Squared is used to measure the intensity of the trend and the effectiveness
of the Linear Regression Forecast. In other words when the R-Squared has a higher
value the stock is trading close to the regression line and in line with expectations.
Conversely when the R-Squared has a lower value, it means that the stock is trading
randomly at prices far from the linear regression line.
In the chart above, the light green line shows where the Linear Regression Slope has turned positive and the Linear Regression R-Squared has increased above a certain defined level and is rising. This gives a strong positive indication that the stock price will move in the positive direction. The red line indicates where the Slope has turned negative and the R-Squared has also fallen below the level and is falling. This indicates a strong negative market trend.
The Linear Regression R-Squared is useful as a confirming indicator. It also has
predictive value. It can be used with other indicators for identifying possible
entry and exit levels. Since it uses the best fit least squares technique, there
is no delay unlike moving averages. The R-Squared indicator can be used to determine
the confidence and efficiency of the Linear Regression calculation.
It is an intensive calculation. It should not be used by itself. The indicator can
sometimes provide false positive signals, as a high confidence score does not necessarily
mean a 100% probability of price movement being in line with the calculated regression