Donchian Channel

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Common > System Indicator Methods >

Donchian Channel

Previous page Return to chapter overview Next page

Description

A moving average indicator developed by Richard Donchian. It plots the highest high and lowest low over a specific period.

 

 

Syntax

DonchianChannel(int period)
DonchianChannel(ISeries<double> input, int period)

 

Returns mean value (middle band) at a specified bar index
DonchianChannel(int period)[int barsAgo]
DonchianChannel(ISeries<double> input, int period)[int barsAgo]

 

Returns upper band value at a specified bar index
DonchianChannel(int period).Upper[int barsAgo]
DonchianChannel(ISeries<double> input, int period).Upper[int barsAgo]

 

Returns lower band value at a specified bar index
DonchianChannel(int period).Lower[int barsAgo]
DonchianChannel(ISeries<double> input, int period).Lower[int barsAgo]

 

 

Return Value

double; Accessing this method via an index value [int barsAgo] returns the indicator value of the referenced bar.

 

 

Parameters

input

Indicator source data (?)

period

Number of bars used in the calculation

 

 

Examples

ns


// Prints the current upper value of a 20 period DonchianChannel using default price type
double value = DonchianChannel(20).Upper[0];
Print("The current DonchianChannel upper value is " + value.ToString());
 
// Note the above call with a barsAgo of 0 includes the current Upper channel in the value. If we want to check for example for a break of this value, storing the last bar's channel value would be needed.
double value = DonchianChannel(20).Upper[1];
       
if (High[0] > value)
  Draw.ArrowUp(this, CurrentBar.ToString(), true, 0, Low[0] - TickSize, Brushes.Blue);

 

 

Source Code

You can view this indicator method source code by selecting the menu New > NinjaScript Editor > Indicators within the NinjaTrader Control Center window.