The Least-Squares Line

Ultimate Trader uses the Least-Squares Line method to determine the plot points for the Best-Fit trend line.

 

 

Formula for Least-Squares Line:

 

 

The least-squares line uses a straight line

     

 

To approximate the given set of data, (X1,Y1) ,  (X2,Y2) , ...,   (Xn,Yn) , where .

The best fitting curve has the least square error, i.e.,

   

 

 

NOTE: a and b are unknown coefficients while all X1 and Y1 are given. To obtain the least square error, the unknown coefficients a and b must yield zero first derivatives.

 

 

Expanding the above equations, we have:

   

 

 

The unknown coefficients a and b can therefore be obtained:

   

 

where stands for