|
|
|
Log In | Sign Up | ||
Linear Regression and Time Series ForecastLinear regression fits the straight line that best describes a set of prices. In technical analysis it is used in two ways: as a regression line or channel drawn through a block of recent bars, and as a Time Series Forecast (also called the moving linear regression), an indicator that plots the end point of a new regression line on every bar. Both treat the line as a fair-value trend and look at how far, and for how long, price strays from it. How it is calculatedThe line is found with the least squares method: of all possible straight lines through the last N closes, it is the one that minimizes the sum of the squared vertical distances between the closes and the line. x = bar number 1 ... N, y = close slope b = (N × Σxy − Σx × Σy) / (N × Σx² − (Σx)²) intercept a = (Σy − b × Σx) / N line value = a + b × x The slope is the trend’s average gain or loss per bar. The value of the line on the last bar (x = N) is the current regression value, and that is what the Time Series Forecast plots. Many charting packages add one more bar of slope (x = N + 1) so the indicator projects the next bar instead; the difference is small, but worth knowing when you compare platforms. A regression channel adds two lines parallel to the regression line. In the original version, often credited to Gilbert Raff, they pass through the close farthest from the line. The more common modern version places them a set number of standard deviations (usually 2) above and below it, which is how our channel is built. How traders use it
Settings and common mistakes
Live chart: SPY (S&P 500 ETF), daily, with a 100-day linear regression channel two standard deviations wide. The chart updates every trading day. Screen for it on MarketInOutOur formula language has the regression channel as exch(nyse,nasdaq) and type(stock) and price > 1 and advol(21) > 1 and slr(100,2) > 0 and price bon_up llr(100,2) Stocks breaking above the upper channel line on above-average volume: exch(nyse,nasdaq) and type(stock) and price > 1 and advol(21) > 1 and price ca ulr(100,2) and rvol(21) > 1.5 Related: Trend lines, Moving averages, Standard deviation. |
Disclaimer - Privacy Policy - Terms of Service - Cookies - FAQ - Affiliates - Blog |