Linear regression slope
The slope of the best-fit straight line through the last N closes.
What it shows
A linear regression fits one straight line through the last N closes so that the total squared distance to the points is smallest. The slope of that line is the average change per bar over the window.
We use N = 50. A positive slope means the fitted line rises. We show it as percent of price per bar.
How we find it
The same code that draws it on your chart follows these steps, with the same result every time.
- Take the last 50 closes.
- Fit the least-squares line.
- Slope = change in the line per bar.
- Divide by the average price to get a percent per bar.
Starting values: N 50. These are proposed and will be tuned on real price data before launch.
How to read it
- The blue line is the fitted line.
- The panel shows the slope over time.
- Zero means a flat fit.
Status labels you may see
| Label | What it means |
|---|---|
| Rising | Slope above 0.05% per bar. |
| Flat | Between −0.05% and 0.05%. |
| Falling | Slope below −0.05% per bar. |
What cancels it
Nothing cancels it.
What traders check next
- R-squared (fit quality).
- Slope changes.
- Window.
Limits
- Prices are not straight lines.
- End points are affected by one outlier.
- Window is a choice.
Try it in forecastviz
- Open any ticker and choose Statistics and risk → Linear regression slope in the left menu.
- Switch between 3M, 6M, 1Y to see how the picture changes.
- Compare with Linear regression channel and R-squared of the trend fit on the same chart.
Questions
Is it the same as a trendline?
A trendline is drawn by hand through swing points. A regression uses every close.
What is R-squared?
How well the line fits, from 0 to 1.
Related trends
Further reading
- Kaufman, Trading Systems and Methods
- Achelis, Technical Analysis from A to Z
- Mandelbrot, The (Mis)Behavior of Markets
- Sharpe, Mutual Fund Performance
Educational only. Not financial advice, and not a price forecast. Charts are drawn by code from past price data, which may be delayed.