# R-SQUARED

## What is R-Squared?

As a statistical tool, R-squared is a measure of how well the regression predictions fit a set of real data points. It measures the disparity between the linear regression and the underlying data it follows. If programmed out, this can be used as a useful tool for traders.

As the calculation indicates how closely the linear regression indicator fits with the underlying price, the higher the R-Squared or *R*^{2 }value, the higher the correlation with the underlying trend in price action. An *R*^{2} value of 1 would indicate the regression predictions fit the data perfectly.

The period or amount of time chosen to input a historic data series, naturally relates to the point at which *R*^{2} correlates positively with the underlying price movement and linear regression; they are inversely proportional.

The shorter the R-squared length, the higher the R-squared level needed for correlation. Although there is no set default level for R-squared length while trading, it should correspond to the length of the underlying linear regression.

## Square the oscillations.

We will code the indicator between levels, whereby the R-squared moves between zero to 1.0. While rising it signals a stronger correlation. A decline would indicate the opposite, between linear regression and the price that is trending. The price chart in Figure 1 of the FTSE uses the 20-period linear regression line in blue over the price, along with a 20-period *R*^{2} oscillating below the price, with markers on 0-1. The arrows on the chart show when the rising R-squared indicator reached or exceeded the 0.20 levels to confirm a trend.

As we can see in this FTSE chart, I have highlighted with a dashed green line, when the oscillator rises from the 0.2 level. this corresponds well with prevailing trends in the price. Notice that as a statistical measure it does not distinguish the direction of the trend, but highlights some strong moves in the price.

## False Signals.

As with the chart above and many indicators, false signals are always an issue. One solution is to raise the threshold until at least the 0.5 line. This cuts out a lot of the false signals however also misses the start of significant large moves.

To combat this we could instead add a conformation indicator, for the figure below I have chosen a standard MACD and placed specific bands around the R Squared oscillator. This serves a manifold purpose; as the R Squared turns below or above the bands, or crosses below or above the bands, and is then confirmed by the MACD crossing the trigger line, far clearer signals are given as below:

As we can see, the general trend of them confirming each other provides support for the direction of the trend. However on the less frequent occasions where the MACD crosses at exactly the point the R Squared crosses below the upper threshold, very strong trends follow. As in Jan and Oct 2018. The same is evident in reverse, the MACD crossing above the 0 line and the R squared crossing above the lower band. This is true of Oct, Dec 17 and April 18.

## R-Squared Compared

One of the major broader applications of this would be the comparison of one security to another, a classic example would be to view the R squared number as a percentage, relating to how much the underlying stock movement effects the current stock. Naturally, when comparing the FTSE to itself we would expect a perfect correlation of 1, with the individual constituents of the index to be varying in their weights. As below:

We take the FTSE in the chart above, Directly below with an R-squared of 0.89 we have the FTSE VS Rolls Royce. Explaining that the underlying stock moves very strongly with the index. Conversely the two charts below show the R squared value of 0.30 for the United Utilities chart. Indicating a much looser relationship with the parent index.

## Scan the Squared.

It would make sense then to use the indicator in a scanner. Scanning bond indices to find the R-Squared value in a fixed income security versus the index. Or scanning the German Dax for example and then listing in weighted order the constituents that have the highest R-squared. Which is what I have done below, starting with Siemens:

## Coding the Square.

What is a pirates favorite indicator?….The ARRRR squared. How do you create the R-squared? Well naturally you multiply Blackbeard with Jack Sparrow. Unlike my niche indicator jokes, we have the rather less comical but much more pragmatic Equilla code for this oscillator below. Notice the coefficient function to calculate R. Coefficients is something we utilize in other articles. We may in the future explore what happens if we turn this oscillator into a strategy. For further information on this or any of our articles, please make contact!

The concept of R-squared has been discussed many times over the years in trading and proves a useful statistical tool. Other authors who explore this subject very well are Markos Katsanos (mkatsanos.com) and further discussion can be found in the *Technical Analysis of * STOCKS & COMMODITIES magazines on traders.com

Tradesignal® is a registered trademark of Tradesignal GmbH. Unauthorized use or misuse is strictly prohibited. Data by Refinitiv EIKON.

Copyright www.welovealgos.com. Terms of use: welovealgos.com/terms-conditions