I was going through the first answer on How do I calculate a trendline for a graph?. The answer says
Given that the trendline is straight, find the slope by choosing any two points and calculating:
(A) slope = (y1-y2)/(x1-x2)
Then you need to find the offset for the line. The line is specified by the equation:
(B) y = offset + slope*x
So you need to solve for offset. Pick any point on the line, and solve for offset:
(C) offset = y/(slope*x)
I'm pathetic in Math. So I need some help to understand the equation in programming term. Lets say I have stock data containing Date, Open, High Low, Close and Volume. If I am not wrong I have to calculate X Axis first as per this answer Calculate a trendline when the x-axis uses dates I could use mysql query to calculate X1-X2( which I am assuming difference between First and Last Date). And for Y axis Last Low Price - First Low Price (Still Assuming). But in next stage I'm stuck. How would I calculate x or offset and on third y? Can someone please help me to understand it?