# Donchian Channels

A moving average indicator developed by Richard Donchian. It plots the highest high and lowest low over the last period time intervals.

The Donchian Channel is a simple trend-following breakout system. The signals derived from this system are based on the following basic rules:

1. When price closes above the Donchian Channel, buy long and cover short positions.

2. When price closes below the Donchian Channel, sell short and liquidate long positions.

By default, the channels are offset by one bar so the channel shows the highest high for the period as of one bar ago.  This allows for breakouts.  You can modify this using the Offset parameter.

Custom PCF Formula
 Of Price Base On High and Low Top `MAXHx.z` `x`=Period, `z`=Offset Bottom `MINLx.z` Center `(MAXHx.z + MINLx.z) / 2` Of Price Based On Close Only Top `MAXCx.z` Bottom `MINCx.z` Center `(MAXCx.z + MINCx.z) / 2` Generalized Top `MAX(w, x)` `w`=OffsetFormula, `x`=Period Bottom `MIN(w, x)` Center `(MAX(w, x) + MIN(w, x)) / 2`

Where x is the period which must be an integer.

Where z is the offset which must be an integer.

Where w is any formula returning a numeric value if the offset is zero. If the offset is not zero, then an offset version of the formula must be manually created for inclusion in the generalized version.

### Examples

The top Donchian channel 50, 1 based on high and low can be written as follows.

MAXH50.1

With the bottom channel being the following.

`MINL50.1`

And the center channel being the following.

`(MAXH50.1 + MINL50.1) / 2`

Changing to price based on close only means replacing all instances of H and L in the formulas with C instead. So the top Donchian channel 21, 1 can be written as follows.

`MAXC21.1`

With the bottom channel being the following.

`MINC21.1`

And the center channel being the following.

`(MAXC21.1 + MINC21.1) / 2`  