Donchian Channel

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
shanemcdonald
Posts: 196
Joined: 08 Aug 2012
Has thanked: 41 times
Been thanked: 41 times

Donchian Channel

Postby shanemcdonald » 16 Nov 2014

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");

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Donchian Channel

Postby MAtricks » 21 Nov 2014

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".

shanemcdonald
Posts: 196
Joined: 08 Aug 2012
Has thanked: 41 times
Been thanked: 41 times

Re: Donchian Channel

Postby shanemcdonald » 21 Nov 2014

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


Return to “User Contributed Studies and Indicator Library”