Trendline formula

dima777

Member
Messages
85
Likes
1
Hi!
I wonder if a simple mathematical formula can describe how a trendline is calculated in such popular charting packages like TradeStation or Metastock? Please let me know what you think!
Thanks!
Dima
 
This is very intresting, but i wonder if its really possible to write a formula for that.... :(
 
You can calculate the line of best fit using OLS regression. If you have Excel use the LINEST function.

It will then give you an equation for the line which can be used for forecasting: basically the slope of the line.

It will also give you R-squared which is a number between 0 and 1 - the closer to 1 the better the line fits the data.
 
Last edited:
You can calculate the line of best fit using OLS regression. If you have Excel use the LINEST function.

It will then give you an equation for the line which can be used for forecasting: basically the slope of the line.

It will also give you R-squared which is a number between 0 and 1 - the closer to 1 the better the line fits the data.

The line of best fit is arbitrary in the fact that the chart drawer, himself, has to decide on the length of time on which the line is based.

If you have Sharescope, it can be seen that a 1 month, 3 month, 6 month, whatever, all have different trendlines. Therefore, even the most carefully calculated mathmatical trendline is flawed because it is dependent on the data provided. Trendlines change course as frequently as an average line does.
 
OK, which one do you want?

Lineal, polynomial, logarithmic, exponential, power, R-squared value or moving average?

Because, before you start, you must be sure that you have the right one for your needs.

Also, as I said before, you need the length of the line.
 
No need to overcomplicate things. If you're looking for standard practice and a straight trendline which a large number of market players can see, then follow these steps:

(1) Can you connect at least 3 highs or lows by hand, which visually seem to be almost a perfect fit?

(2) Look at what the trendline is saying for today: is it close to some meaningful support or resistance? If so, use the S&R as a priority.

If after (1) and (2) you still want the formula that the software package gives, then it will be of the form:

y = a + mx

which might give a result such as y = 12000 -100x

If your data starts on a Monday and you want to know where the trendline comes in on Friday
just type in 5 for x, giving a value of 11500.

It's as simple as that.
 
Last edited:
Drawing in a trendline by eye is the way I do it. It's quick and likely to be more accurate to your way of thinking because you can see, immediately, where you are coming from. ie. the trend that you are interested in.
 
yes you certainly can, but takes effort.

It is quite complicated to program but you can do it. You have to study the dictionary area menu and you will find lots of trendline type stuff in there. Note there is a difference in commands between drawing trendlines and then using them for trading, but if you can learn how to program in their being drawn automatically, at that point you will be able to use that underlying code to generate signals since you can have the signals key of the variables in which the trendline values are held.

Eminiwatch.com sells a very good trendline application for only $50.00 or so but the source code is protected. But you can see from the graphics on his site that clearly it is possible. I do some TS work but find trendlines very hard to work with, but definitely you can. No question about it.

I have not looked but I bet you they have some sample code on their forum.
 
Top