Skip to main content
Track Linear regression
34 / 43
Library

2004issue C101

Constructing least-squares trendlines from ordered prices

A least-squares centerline through ordered prices is fully specified by an intercept and a slope. Those two constants can be recovered from a declared lookback, so the trend is a constructed object rather than a line drawn by eye.

  • A least-squares fit is the unique straight line that minimizes the sum of squared vertical misses from an ordered sample, and it is fully specified by an intercept and a slope.
  • Intercept and slope can be recovered from five worksheet totals: the observation count, the sum of the time index, the sum of the data, the sum of squared time, and the sum of time multiplied by data.
  • The same two-constant construction applies when a stock price is vertical and a broad index is horizontal, where intercept and slope correspond to the alpha and beta constants used in stock analysis.
  • A line drawn by eye remains open to disagreement; the two fitted constants remove that drawing discretion and describe the trend over the chosen lookback.
Entries in this reading1 entry

A centerline from two constants

A centerline is a straight path drawn through the interior of an ordered price series rather than through successive highs or lows. A straight line through an ordered sample is defined by choosing intercept and slope so the sum of squared vertical deviations is minimized. That choice is the least-squares fit: the unique straight line that makes the sum of squared vertical misses from the sample points as small as possible.

The finished line is fully specified by two constants. The intercept is the fitted level of the series when the horizontal variable is zero. The slope is the constant change in the fitted level for each one-unit step along the horizontal axis.

Worksheet totals and lookback

Intercept and slope can be recovered from five worksheet totals: the observation count, the sum of the time index, the sum of the data, the sum of squared time, and the sum of time multiplied by data. For the five-point teaching sample whose totals are observation count 5, time sum 15, data sum 13, squared-time sum 55, and time-times-data sum 44, the fitted constants are intercept 1.10 and slope 0.50.

The lookback is the fixed count of ordered observations used to compute the intercept and slope. The construction accepts any length of ordered sample and may slope upward or downward, giving an objective description of the trend over that lookback.

Time, another series, and a log scale

The same two-constant construction applies when a stock price is vertical and a broad index is horizontal. The intercept and slope then correspond to the alpha and beta constants used in stock analysis. In that setting the result is a regression line: the least-squares line obtained when one market series is placed on the vertical axis and time, or another series, is placed on the horizontal axis.

On a logarithmic vertical scale, a straight centerline through a price channel states a constant percentage growth or decline rate. A line drawn by eye through the same points remains open to disagreement. Replacing it with the two fitted constants removes that drawing discretion.

Educational research material, not investment advice. Historical source context does not establish present-day performance.
34 of 43 in the Linear regression track
20071-7 pp.Next on Linear regressionRectangle breakout targets beyond heightA rectangle is sideways price action bounded by two horizontal or nearly horizontal parallel lines, typically defined by at least two points on each line and more often by three.
All readings on this track · 43 readings
  1. 1990Constructing dollar baselines from rates, inflation, and residuals
  2. 1990Constructing a nominal index value from forward earnings and fitted yield
  3. 1990Constructing a nominal index price from earnings and a fitted yield
  4. 1990Endpoint-pinned price paths are not forecasts
  5. 1990Constructing least-squares polynomial smoothers
  6. 1991Endpoint growth rates versus linear-regression consistency
  7. 1991Out-of-sample checks for linear growth fits
  8. 1991Trend as persistence, not a straight line
  9. 1991Quadratic trend, residual oscillator, and a secondary cycle calendar
  10. 1991Time-origin offset and residual-price divergence on a quadratic least-squares fit
  11. 1991A least-squares trendline from ordered prices
  12. 1992Constructing log-linear growth and reliability screens
  13. 1992Constructing log-linear growth-rate baselines
  14. 1992Next-session high, low, and close from rolling linear regression
  15. 1993Auditing an index price-earnings multiple with short-rate regression
  16. 1994Regression-seeded nested exponential price filter
  17. 1994Constructing the double exponential average from lag cancellation
  18. 1994Evaluating money supply as a linear leading-index baseline
  19. 1995Constructing least-squares trend channels
  20. 1995Linear baseline holdout checks for annual bill-rate forecasts
  21. 1995Projection bands from high and low regression slopes
  22. 1995Evaluating a least-squares end-point moving average on a known test series
  23. 1996Constructing an endpoint moving average from a least-squares line
  24. 1996Scoring equity path consistency with a k-ratio overlay
  25. 1996Evaluating month-end yield gaps for equity regimes
  26. 1996Constructing session-indexed standard error bands
  27. 1998Evaluating linear regression baselines for index valuation
  28. 1998R-squared as a two-state trend filter from a price-time fit
  29. 2000Second-order moving-average lag correction
  30. 2002Price regression line versus beta for index tracking
  31. 2003Regression slope with an r-squared trend confidence gate
  32. 2003Constructing finite-volume-element divergence with slope comparison
  33. 2004Building a daily score from regression, retracement, and volume
  34. 2004Constructing least-squares trendlines from ordered prices
  35. 2007Rectangle breakout targets beyond height
  36. 2007Confirming a price trend with regression slope and r-squared
  37. 2008A linear-regression angle assembled as one trend filter
  38. 2010A two-state swing machine from four running extremes
  39. 2016Score oil-complex tightness before divergence or regression
  40. 2017Nikkei-yen intermarket divergence as a regime case study
  41. 2017Constructing Calmar ratio and linear regression baselines
  42. 2019Pair-trade layer construction versus average-spread management
  43. 2020A convolution slope built from nested linear regression
All 112 readings tagged Linear regression
Also on Linear regression5 readings