Filtering Trends with Linear Regression Analysis
Please don’t be intimidated by the headline – I promise it’s a lot easier than the title sounds! Some time ago I wrote an article about indicators you can use to filter trends. This means that you identify when the price of something has been moving up or down over some time. The article researched using a few filters and found that major breakouts and the ADX indicator could improve the raw trend results. There is another filter I overlooked, and I want to cover this today: linear regression analysis. What is it and how does it work?
Linear regression is just a mathematic model that plots the line that most closely fits the prices in a chart. The line drawn is straight. From this line two important metrics can be calculated: the slope of the line, which can tell you the direction and exact angle of the trend, and “R squared”, which tells you how closely the prices fit to the line running most directly through the trend. For here is a curious fact: trends are usually more reliable when the price “hugs” the trend line, if the price moves wildly with mots of deviation from the average, the trend is less likely to keep moving. This means that when you are trading a trend, the more “orderly” the trend looks, the better your odds of success should be. We can illustrate this with some research.
I took historical daily prices of the EUR/USD currency pair from 2001 until a few weeks ago. The average daily directional price movement was 0.00%. I then applied a 20-day linear regression and went long each day there was a meaningfully positive slope and short each day there was a meaningfully negative slope. This covers trend direction, although it needs to be noted that 20 days is very short. This gave results that were a little worse than random! Finally, I added a filter to the slope, where the R squared value had to be in the top half of its potential range (between 0 and 1, so 0.5 or greater). This improved the results, producing an average daily win of 0.01%, and a win rate of about 51.30%. These numbers are small, but using over 4000 days as a large sample over 16 years, does mean that the result is significant.
Most charting software includes a linear regression analysis which will plot the line on the chart, showing standard deviations either side (which you can customize), as well as values for the slope and R Squared.