Fitting a trendline by least squares
by Arthur A. Merrill
Trendlines usually are drawn through tops or bottoms. They also are drawn through the center of prices
by a lagged moving average or by eye (Figure 1). A straight line through the center of a price channel, if
the scale is logarithmic, will give you the percentage growth or decline rate.
If the straight line is drawn by eye, it is subject to debate. This doubt can be resolved by a mathematically
calculated line called "least squares" (Figure 2). The deviations of the points from the line are A, B, C, D
and E. The line produced by the least squares calculation reduces the sum of the squares of these
deviations to a minimum, hence the name "least squares."
Now, the formula for a straight line is:
Y = A + BX
X is the value of the X axis and when X is zero, Y equals A, which is called the Y intercept (Figure 3).
The distance from this level up to the line is BX, which is directly proportional to B, the slope of the
regression line. X is the value of the X axis.