From the blog "Quantitative Financial Insights"
|18 Feb 2010||Helen Chen||
"For all of you building your own code to trade or backtest your quant models, i am posting a piece of code to calculate price channels based on 2 time windows.
For example, If you want to build and back-test a trend-following system, turtle style, you will need a moving channel of lowest and highest X-day closing price. If price breaks out, you should open a position. Converserly, if price moves in the opposite direction after a break-out, you should put stops in channel of X-N size. Usually, you can try that with 20 and 10 days windows."