In the lead up to building my first algo, I'm trying to build a system to only trades in the direction of the trend (both the bigger picture trend AND the trend of the day). This leads to the basic question of how to tell a computer quantitatively to define a trend, both in the longer time frame and shorter day time frame, and conversely how to define when that trend has been broken.
The "Definition of a Trending Day" thread started by Bike Mike provided a good foundation of research, but I wanted to get the input of a few of the more sophisticated programmers how to weight these basic inputs (and also which combination of these should be used):
1. Starting with the most basic of filters, maybe a higher time frame moving average such as as long as price is above or below the 50 day moving average.
2. Using a combination of trend lines. But this begs the question of which existing trend line indicators produce the most consistent results of higher highs/lower lows, etc. This also begs the question of how much tolerance of a break of the trend lines before the trend is considered broken. I've looked at a De Mark type trend line before but don't have exceeding confidence on the consistency of that trend line as opposed to simply manually drawing the trend lines.
On more complicated quantitative definitions...
3. A trend could be mathematically defined as a situation where there are successive higher highs, but more importantly that the lows do not close below the previous high.
What type of code might best express this?
4. While #3 could be the cleanest definition and safest style of continuation trades, one could further say that a violation of a previous high does not stop the trend, price must close below the point of control of the previous balance area before the trend is broken.
But what is the best way to quantitatively define the previous balance area?
What is the best way for a program to define that balance areas point of control?
And how many balance areas can be invalidated before the trend itself is invalidated and therefore the program should no longer be looking for continuation trades in the original direction?
5. What other ways can a trend be mathematically defined that aren't being considered here? And which combinations are the superior ways of defining what the human mind can easily see?