Page 1 of 1

Donchian Channel

Posted: 16 Nov 2014
by shanemcdonald
This is a Donchian Channel from Trader's Exchange .

Code: Select all

// Donchian Channel
//
// http://www.tradersxchange.com

Inputs:
Base(close),
Length(13),
ShowAvg(true);

Variables:
DonHigh(0),
DonLow(0),
DonAvg(0);

DonHigh = Highest( base, Length);
DonLow = Lowest( base, Length);
DonAvg = ((DonHigh + DonLow) / 2 );

Plot1(DonHigh, "DonchianHi");
Plot2(DonLow, "DonchianLo");

if ShowAvg = true
then Plot3(DonAvg, "DonchianAvg");

Re: Donchian Channel

Posted: 21 Nov 2014
by MAtricks
Thank you for posting this commonly used tool. However, I see an error in this piece of code: Using the high/low of the recent Close prices doesn't seem very accurate. The Donchian Channel uses the highest of the highs and lowest of the lows. Try this:

Code: Select all

Inputs:
Length( 20 ) ;

Variables:
DonchianHi( 0 ),
DonchianLo( 0 ),
DonchianAvg( 0 ) ;

DonchianHi = Highest( High, Length ) ;
DonchianLo = Lowest( Low, Length ) ;
DonchianAvg = ( ( DonchianHi + DonchianLo ) / 2 ) ;

Plot1( DonchianHi, "DonchianHi") ;
Plot2( DonchianLo, "DonchianLo") ;
Also, similar code is usually included in with MC or TS libraries under the name "Price Channel".

Re: Donchian Channel

Posted: 21 Nov 2014
by shanemcdonald
Thanks for the code !

I only posted it because the Price Channel does not have the mid point.

I could not get the mid point set up properly myself. So I use the Donchian I found on Traders Exchange.

thanks for the new code, its great !

shane