For painting you don't need the equation, if you have the bar and the price from e.g. the minima, plot it with:

Code:
plotGraph("Line",LocalMin1_Bar,LocalMin1_Price,LINE,BLUE);     
plotGraph("Line",LocalMin2_Bar,LocalMin2_Price,LINE|END,BLUE);


But how do you determine useful minima/maxima for trend lines?