Donchian Channel

View as Markdown

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

inputIndicator source data (Series<T>)
periodNumber of bars used in the calculation

Examples

1// Prints the current upper value of a 20 period DonchianChannel using default price type
2double value = DonchianChannel(20).Upper[0];
3Print("The current DonchianChannel upper value is " + value.ToString());
4
5// 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.
6double value = DonchianChannel(20).Upper[1];
7if (High[0] > value)
8 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.