- Tucker Report - http://tuckerreport.com -

Linear Regression Angle Measurement

Posted By Doug Tucker On July 25, 2007 @ 9:29 pm In | Comments Disabled

In my testing, linear regression curves seem superior to moving average to determine trend. All determinations of trend have lag, but the regression curve seems to offer better support and resistance, seems to turn at points that can contain price better on re-tests, and can offer more timely clues as to price direction by observing the angle of the regression curve. I have explained the basics of the linear regression curve in the Standard Error Bands [1]and R-Squared [2]articles in this section. I won’t repeat what a regression curve is. Please go to those links if you need more information on what a linear regression curve is.

The angle of an indicator can be easily measured using the arctangent function, which is available in TradeStation, as well as most other programs. The difficulty in measuring the regression curve would present the same problem as trying to measure the angle of the side of a basketball. It is a curve, not a straight line. One could measure the actual linear regression line at each point along the curve, but it would be cumbersome to compute. To measure the angle of a curve you could take the current point on the regression curve and compare that with the previous point. That seems to be too fine a resolution. You could take the current point and the point 10 bars back, but you’d miss the beginning of the turn. There is no perfect solution, but I’ve decided for now, at least until I come up with a better idea, to take the current point on the regression curve and compare that with the average of two or three bars back. That seems a good compromise. Refer to the following chart.

lra1.gif
The upper graph shows the prices with a fairly long term and smoothed linear regression curve. I chose the Dow mini futures on a very short-term tick chart because I readily found many examples of whippy but trending price patterns. There would be no difference in the concepts if used on daily charts.

The lower subgraph has the result of the arctangent line, which I’ll call it the angle measure, that corresponds with the angle of the above regression curve. I am using the current value and measuring the angle with the average of the previous few bars. The dashed cyan line is the zero basis line, so the bright blue line is indicating an up angle in the regression curve if it is above the basis line. A down sloping curve on the regression line is indicated if the angle measure is below the zero basis line. The two vertical lines on this chart reference the point where the angle measure crosses the basis line, which is the same point that the regression curve changes direction. One note about the angle of a regression curve: if you actually take a protractor and measure the angle of the line on your monitor, the angle measured will depend on the scaling of the chart, size and shape of monitor, how many indicators are in the sub-graphs, how tightly bars are squeezed together, etc. Therefore, the actual numbers being computed by the indicator may not correspond exactly with the actual angle as visually seen. However, the general direction of the regression line, its acceleration or deceleration, and most important, the point of the change of direction will all be accurate, even if the actual numbers differ.

Point 1 shows the angle measure is negative but increasing toward the basis line. You can see that the regression curve on the price chart as still pointing downward, but progressively at a less steep angle. At point 2 the angle measure goes positive at the same point as the regression curve on the price bars changes direction from down to up.

Point 3 shows a steep uptrend in the regression curve. Notice how the angle measure line rises steeply at the beginning of the move, but then flattens out, indicating that the regression curve is still trending up at a steep angle, but the angle is not accelerating. Point 4 shows a minor divergence as it tries to up-tick a few bars, and then starts declining. This is almost imperceptible on the actual regression curve, but is very clear on the angle measure. Point 5 shows an even more pronounced divergence as prices try for a new high, and fail. Point 6 shows the cross of the zero basis line, with the regression curve turning down on the same bar. Point 7 indicates a steep angle down, as is evident on the regression curve itself.

lra4.gif
Above is the same chart, but a second regression line is added. The parameter use is much shorter. The idea was to have a trigger to enter trades in the direction of the longer-term trend, or perhaps to offer points of divergence ahead of the trend changing. Triggers in this example would be pullbacks within the trend such as the short-term angle measure turning up from under zero line, or sells in downtrends with downturns over the zero line. Point 1 was not a good example as the longer-term angle measure was up trending toward the zero line. Point 2 was a nice pullback under the zero line with the trend still accelerating. Point 3 was similar, but angle measure was no longer accelerating, but still at a high level. Entry there would have had some gains. The same with point 4 and point 5. The parameters of these two lookback periods and smoothing have not been optimized in any way. I just wanted to show a possible application of this idea.

lra5.gif
Above is the same contract but on a different day. You can see on the left side of the chart how persistent the trend is. The angle measure is at a high level, but very flat. Points 1, 2, and 3 would have offered profit potential. The peak after point three diverged significantly from the new high in price, and the longer term angle measure was starting to decline a bit, although on the price chart the regression curve looked like it was still advancing strongly. As prices formed a head and shoulders top, the short term angle measure kept declining from lower levels. The longer-term angle measure eventually crossed the zero basis line, but was in a steep descent for some time.

Point 4 was a downturn in the short-term angle with a still steep angle in the longer term. Point 5 was a warning as it turned up with a slight upmove beginning in the longer-term angler measure. Point 6 was an upturn once the longer-term angle was back to the upside.

lra6.gif
The above chart is the same price series, this time with the two angle measure lines from the previous example added together and plotted as a histogram. The color changes from red to green occur when the direction of the histogram changes. Point 1 shows a nice upturn from above the zero line, although the histogram changed direction a few times before it made up its mind. Point 2 is similar. Point 3 shows a flat area with no real direction. The summation of the long term and short-term angles were near zero, and you can see prices are flat as well. Point 4 starts to break down, and with the exception of one green bar, the histogram follows the prices down on that first leg, and resumes at point 5 for the rest of the down-move. Point 6 tries to resume the down-move. It turns up at point 7. Prices are still in a downtrend, but after a few bars the histogram goes positive and a large upmove occurs. Point 8 catches the top when it turns back down. Point 9 catches the next upswing.

lra7.gif
Here is the same chart again, this time with the actual angle measure line included with the histogram.

lra8.gif
Here is another example from a different time period. Point 1 has the short-term angle advancing sharply as the long-term is nearly crossing the zero line, with the exit at point 2. The upturn in the short-term angle line caught a bit of the upturn between point 2 and 3, with point 3 a perfect exit. Point 4 was a nice short as the long-term angle measure was heading down, and prices were resisting right at the rounding over long term regression curve. Point 5 was a continuation down. The short-term line didn’t get over the zero line, but the histogram resumed its red bars. Point 6 was another good short. Point 7 might have been a good long entry with the rounding up of the angle measure, despite the angle still being down.

lra9.gif
The above chart shows a possible use as a tool to confirm divergence. Point 1 shows price trying to make a new high. Point 2 on the histogram of the angle measures shows clear divergence. Notice how long the histogram bars kept declining through point 3.

anglesnew.gif
The above chart I just added a day after I originally posted this article. It is the YM late in the day as it tried to recover from a big selloff. I thought this chart was interesting as the summation lines (histogram) really captured the impulses very accurately, and reversed right at the reversal points in price. The long term line stayed in a steady uptrend throughout most of the chart. The line was flat as it wasn’t accelerating, but it was steadily at a high level. Most of the summation, or histogram, bars were influenced mostly by the short term regression angles. Also notice again how well the long term angle measure rolled over very quickly right before the regression curve on prices rolled over.

Using angle measurement on regression curves may or may not be the basis of creating a trading approach, but I do believe that do so can give valuable clues to subtle changes in trend that might not be apparent from looking at prices and regression curves alone. Linear regression curves tend to accelerate and decelerate faster than traditional moving averages, and measuring the angles can help see this much more clearly. This is ongoing research so I will update this post as I progress.

ADDED on SEPT 3rd, 2007. I’ve had many emails regarding this subject. I want to clear up an important point on measuring angles on charts. When you measure an angle whether doing so with a protractor or and arctangent function, the angle measurement you receive is NOT invariant. The angle will depend entirely on the scaling of your chart. To prove this just insert any fairly long moving average that looks like it maintains about a 45 degree angle, and then overlay a Gann angle, or any kind of trend-line your charting package can display that fixes the angle to a degree you specify, rather than on data points. Set the angle to approximate the angle of the moving average on your chart. Then squeeze the bars tighter. You will notice the fixed line you drew maintains the same angle, but the visual slope of the moving average is now steeper. Then widen the bar spacing out a couple of time. The moving average is now less steep. Now insert an indicator or two under the price bars. Now the moving average is much less steep. If you add enough indicators, the moving average can look relatively flat. It is amusing to see people post in day trading chat rooms that the angle of the moving average isn’t steep enough to take a trade. Steep enough relative to what? It all depends on the scaling of the chart, the size of screen, whether screen is horizontal or vertical, number of indicators, etc etc. So I find the angle measure presented here very useful, but you have to keep in mind that the values displayed are relative and have to be interpreted that way. You can’t think of the angle measures in absolute terms. The relative steepness between two regression curves, and the turning point from up to down of those curves is the important information, not the actual numbers. This aspect of measuring angles is also why I reject most Gann techniques. Hope this clears up some confusion.


Article printed from Tucker Report: http://tuckerreport.com

URL to article: http://tuckerreport.com/indicators/angle-measure/

URLs in this post:

[1] Standard Error Bands : http://tuckerreport.com/indicators/error-bands/

[2] R-Squared : http://tuckerreport.com/indicators/r-squared/

Copyright © 2010 Tucker Report. All rights reserved.