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.
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.
All readings on this track · 43 readings
- 1990Constructing dollar baselines from rates, inflation, and residuals
- 1990Constructing a nominal index value from forward earnings and fitted yield
- 1990Constructing a nominal index price from earnings and a fitted yield
- 1990Endpoint-pinned price paths are not forecasts
- 1990Constructing least-squares polynomial smoothers
- 1991Endpoint growth rates versus linear-regression consistency
- 1991Out-of-sample checks for linear growth fits
- 1991Trend as persistence, not a straight line
- 1991Quadratic trend, residual oscillator, and a secondary cycle calendar
- 1991Time-origin offset and residual-price divergence on a quadratic least-squares fit
- 1991A least-squares trendline from ordered prices
- 1992Constructing log-linear growth and reliability screens
- 1992Constructing log-linear growth-rate baselines
- 1992Next-session high, low, and close from rolling linear regression
- 1993Auditing an index price-earnings multiple with short-rate regression
- 1994Regression-seeded nested exponential price filter
- 1994Constructing the double exponential average from lag cancellation
- 1994Evaluating money supply as a linear leading-index baseline
- 1995Constructing least-squares trend channels
- 1995Linear baseline holdout checks for annual bill-rate forecasts
- 1995Projection bands from high and low regression slopes
- 1995Evaluating a least-squares end-point moving average on a known test series
- 1996Constructing an endpoint moving average from a least-squares line
- 1996Scoring equity path consistency with a k-ratio overlay
- 1996Evaluating month-end yield gaps for equity regimes
- 1996Constructing session-indexed standard error bands
- 1998Evaluating linear regression baselines for index valuation
- 1998R-squared as a two-state trend filter from a price-time fit
- 2000Second-order moving-average lag correction
- 2002Price regression line versus beta for index tracking
- 2003Regression slope with an r-squared trend confidence gate
- 2003Constructing finite-volume-element divergence with slope comparison
- 2004Building a daily score from regression, retracement, and volume
- 2004Constructing least-squares trendlines from ordered prices
- 2007Rectangle breakout targets beyond height
- 2007Confirming a price trend with regression slope and r-squared
- 2008A linear-regression angle assembled as one trend filter
- 2010A two-state swing machine from four running extremes
- 2016Score oil-complex tightness before divergence or regression
- 2017Nikkei-yen intermarket divergence as a regime case study
- 2017Constructing Calmar ratio and linear regression baselines
- 2019Pair-trade layer construction versus average-spread management
- 2020A convolution slope built from nested linear regression