Saturday 12 February 2011

110212 - Getting the Picture: Constructing Channels

Drawing simple line indications on your charts can be extremely useful to show exactly what the trend is doing, and whether or not volatility is increasing or decreasing. The easiest way to visualize these important measures is by use of triangles and channels. However, there are many ways to draw even a simple triangle, and each method will yield slightly different results. This is also true of channels: What number of bars do you use? Where do you place the first line? How do you position the second line with respect to the first?

I like to think of a channel as "the range in which prices move over the specified period, bounded by the maximum and minimum deviation from some typical price". From this definition, we can start to get more scientific. Looking for a better way to express this "typical price", I looked at many existing indicators. Of those which approximated what I wanted to see, the majority involved a linear regression calculation to deduce the centre line from which the outer channels are then calculated. The corresponding measure of fit, R-Squared, can also be calculated very cheaply along the way, and displayed if required, in order to assure the viewer that the end result does indeed match the time series.

Once the chosen regression method is understood, it can be coded very simply and efficiently. Personally, I would not want to have these calculations proliferate through my code and be executed on a tick-by-tick basis since they can be compute-intensive, so i made a decision that I would only want to visualize any change at each new bar open. Writing the regression code as a libraray function makes it available for reuse any time I need it, and also, as time goes by and it gets used for more applications, I can be confident that the code is mature and stable. Conversely, some thought needs to be applied to the design, such that perceived future modifications are minimized, reducing the risk that the behavior of dependent code is affected.

At this point, I deviated from the other indicators, after determining that none of them did really what I wanted. I wanted  a channel that "hugged" the prices, the upper boundary touching the high of the bar with the greatest deviation from the centre, and the lower boundary touching the low of the bar with the greatest deviation from the centre. Once the boundaries have been determined, optionally drawing the line which is at the centre of those two limits naturally reveals a difference from the original regression line. I have not found this to be significant, and the final result is exactly what i wanted.





The above chart picture shows EURGBP on the H1 timeframe. I have added 2 instances of the regression channel indicator. The channel drawn with solid yellow lines is the 5 day channel, and the broken yellow lines show the 3 day channel. I have found these 2 periods to be of interest., and will use them in future. Note how they both "hug" the channel nicely. I am not showing the optional centre line, nor one additional feature that I found useful in Expert Advisor testing: drawing the trail. This option leaves a mark at the oldest centre point before the channel is redrawn upon start of the new bar.

If you are interested in obtaining a copy of this indicator, please contact me.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.