Stocks & Commodities V. 22:10 (86): Sidebar: 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. 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.” The deviations of the points from the line are A, B, C, D and E in Figure 1. 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