R Squared is a statistical term comparing the relationship between two variables. The function in the formula is the familiar Pearson’s Correlation Coefficient. R-Squared is the square of this coefficient. For those interested in math and statistics you can Google it and find much information. For those who just want to know how to use this in trading I’ll try to get to the point as soon as I can provide a minimal amount of background.
By using a correlation coefficient, any two variables can be compared. You can compare stocks to indices, or indices to fundamental data, or any two variables you can think of. In trading, the best use of the two variables is to check for linearity of price over time. If you view prices as a scatter plot, for instance tossing a bunch of coins on the floor, you can then try to construct a straight line through where the coins randomly fell to the floor. You are thus relating the data, or coins, to a straight line. Linear regression is an algorithm for drawing this line using the least squares method. You are trying to find the line that best fits the data. You can make an estimate of how well the next coin tossed will fit the line, or measure the error of the forecast. On most traders’ charts this line will be represented as a curve instead of a straight line. The curve is simply the end point of the regression line moved forward with each new price bar and each new regression end point. R-Squared is the statistical measure of how well the data points match the regression line. A value of 1.0 will show that there is a 100% correlation between the regression line and the scatter plot of the data. In trading it is usually assumed that a reading of 0.7, or 70%, would show there is enough explanation of the price by linear regression to assume a trend is in place. One could also assume that the other 30% is just explained by randomness. If the R-Squared reading becomes very low approaching 0, then prices are displaying little or no relationship to the regression line. It is commonly assumed that reading under 0.3, or 30%, indicate a noisy and non-trending market. The input length use for this indicator is commonly set at 30 bars. This is a long enough period to be statistically significant, and still short enough to be timely.
Many traders use moving averages to try to determine trend. In my view linear regression curves are far superior to moving average. Many attempts have been made to take the lag out of moving averages. I have never seen any success doing this. However, moving averages can provide excellent areas of support and resistance, provided the proper length of moving average can be determined. That, of course, is the difficult part of using moving averages. The more well defined the trend, the less important it is to provide the proper moving average input, as the cyclical nature of the market gives way to trendiness, thus any moving average will appear to work.
In the following examples the R-Squared indicator is the red line under the price chart. The horizontal blue line is the .70, or 70% level, and the yellow line is the .30, or 30% level. The little white dots appear on the R-Squared line when it stays over or under either of the reference lines for more than 10 bars.
The above chart show the 233 tick YM (Dow mini futures). The strong uptrend on the left side of the chart shows the market is trending nicely. In other words, prices are following a smooth line as they are moving forward. When prices start to veer away from a smooth line the R-Squared line starts to retreat. It is smoothed so it doesn’t react instantly. There is no indicator without lag. But it is fairly timely in declining as the market starts to move sideways with wider range bars. Ultimately the line retreated to under the 30% level, indicating a choppy market.
The uptrend in the above chart is clear, and indicated by the R-Squared staying over the 70% level (blue line). Then the R-Squared moves under the blue line as price makes one more attempt at a new high. This new high fails, and the indicator indicates the market is no longer in an easy, smooth trend. Of course the trend could have resumed. In this case it started to turn down. The R-Squared indicator fell to the non-trending mode under the yellow line as the indicator was digesting the choppy up and down moves where I placed the numbers. Eventually the R-Squared started to measure the trendiness of the new downtrend and moved up from the non-trending area toward the trending area on the right side of the chart.
Above is a choppy period with most of the R-Squared values at a low level, indicating mostly random price behavior. On the left side of the chart there was a brief trend with little follow through, and again on the right side of the chart there was some hope of a trend maintaining itself as the indicator went to a high level. (The cyan line is a linear regression curve on the price bars.)
Above is an example where the R-Squared really fails to offer much guidance. At point 1 it is showing no clear trendiness, which is correct, and as prices start to advance the indicator starts to pick up trendiness through point 2, which is also correct. Prices fail to follow through for very long and the indicator retreats, but prices enter a quick downtrend and the indicator only picks up on it at point 3 when it starts to turn up, right about the time prices bounce up a bit. At point 4 the indicator is low and suggesting the market is noisy, which it had been where that flat spot occurred on prices a few bars earlier. When the downtrend resumes the indicator started to advance fairly quickly from a low level to the high level at 5. Once again there was no follow through and the indicator had to retreat. In each case the R-Squared tried to get in synch when the market started to display trendiness, but when the trends were cut short and reversed, the indicator couldn’t keep up. The price structure shows a clear pattern of lower lows and lower highs. Sometimes an indicator just doesn’t work as well as it does at other times. Sometimes you need a hammer and sometimes you need a screwdriver. One tool can’t handle every job.
Here is a daily chart of Hewlett-Packard. You can see that the trend started with the R-Squared indicator in the non-trending zone, and once prices started a smooth advance, the indicator went to the trending mode above the blue line and stayed there. When prices started to flatten, the indicator eventually went back under the blue line. The trend was still up and prices were still exhibiting a smooth progression. Had wider range bars been present, or a more pronounces downmove, the indicator would have retreated more quickly. Also note that many of these trends start when the indicator is in a non-trending mode. The indicator only measures trendiness. Not overbought or oversold, and of course, not direction. Markets will cycle back and forth between trending and non-trending mode.
Here is Hewlett-Packard again showing how well the R-Squared can define a choppy period.
In this example on the Intel chart the market starts to trend in the middle and the indicator picks up on it nicely, but the emerging trend fails, and the R-Squared goes right back into non-trend mode. On the very right of the chart the indicator starts to pick up on the possible emerging downtrend. The R-Squared indicator does an excellent job defining the choppy sections on this chart.
The Peabody Energy chart shows the transition from the choppy area on the left, to the trending area in the middle section. When the upmove and trendiness falter the indicator quickly retreats.
In my opinion the R-Squared indicator is an excellent tool to have available. It isn’t perfect, and at times can steer you the wrong way. Often choppy or trending markets can just be eyeballed. But it is good to have an indicator that can help measure the tendency of trendiness that is quantifiable. Keep in mind that at trend changing points the indicator will first assume no trend. It will take a few bars for the indicator to start measuring trendiness of prices as they head in the opposite direction. Most of the time at trend changing points the indicator will be at a very low level, even if the preceding trend was smooth, and the new emerging trend seems to be starting off smoothly. If you have a good signal it would be a mistake to pass on the trade just because the indicator is showing no trendiness. It should catch up if there is follow through to the new trend. But if prices are moving in one direction and the R-Squared goes from trending to non-trending, it’s a good idea to pay attention.