New Trend filter technique

#1
The biggest challenge for trend following or mean reverting systems is to distinguish between trending phase and rangebound phase. I came across an interesting technique that can be of great help called Trend Statistic Filter (TSF). The following description is for daily bars. It can be used on bars of any time frame like weekly, hourly, 5 min, etc.Calculation of TSF 20 is as follows:

We compare the current market price(cmp) or (closing price) to each of the high-low range for last 20 days( or n days). First, if the CMP is contained within the prior days high-low range we consider today as not trending and give a score of 1. If it does not fall within the previous day's range, we give score zero. We then compare cmp with day before yesterday's range and give a score of 1 or 0. The process is repeated for say last 20 days. If the total count comes to say 14, it means 14 out of 20 days market was not trending. As more number of times CMP falls within the daily range of last 20 days, more range bound the market is. We calculate the percentage of days with such overlap and plot this value as trend statistic. Low values of TSF indicate there is less overlapping and market is trending. High STF values suggest more overlapping and market is congested.
Note: It would be great if we use ATR instead of high-low range of each day in calculating TSF.

I found this tool quite interesting. If anyone can write AFL for this, we can easlily scan a large list of stocks to find rangebound / trending stocks.

Regards,
Amrut
 

Similar threads