Trend lines

All lines with 3 or more reaction points are discovered. The strength of a trend line is defined as a number of reactive points.

The definition of a reaction to the trendline is when price
1) bounces away from the line,
2) a threshold is defined, and has to be within specified range in percent depending on volatility to identify how much the price has to divert from the line to consider it as a bounce,
3) the trendline ends when it is broken and a threshold of how much the price has to go through the trendline in order to consider it as a break. 

The algorithm can effectively catch all the trend lines on the chart.