Donchian Channels

eSignal EFS 2

Donchian Channels

Top  Previous  Next

 

upperDonchian( length [, source | sym() | inv()] [, barIndex] )

middleDonchian( length [, source | sym() | inv()] [, barIndex] )

lowerDonchian( length [, source | sym() | inv()] [, barIndex] )

 

Channels are lines that surround a stock price movement, which help in projecting future price action. The Donchian Channel indicator uses the highest high and the lowest low of a period of time to plot the channel.

 

Parameters

 

length

the period to use for the calculation

 

source

optional. input series for the study

default: high and low

sym()

optional. specify a symbol to use

default: current symbol

inv()

optional. specify a bar interval to use

default: current interval

barIndex

optional. bar index of value to retrieve

default: current value

 

To Create a Series

 

var myStudy1 = null;

var myStudy2 = null;

var myStudy3 = null;

var bInit = false;

 

function main() {

var myVar1;

var myVar2;

var myVar3;

 

       if ( bInit == false ) {

               

               myStudy1 = upperDonchian( 20 );

               myStudy2 = middleDonchian( 20 );

               myStudy3 = lowerDonchian( 20 );

 

               bInit = true;

 

       }

 

       //retrieve the current values

       myVar1 = myStudy1.getValue(0);

       myVar2 = myStudy2.getValue(0);

       myVar3 = myStudy3.getValue(0);

 

       return new Array( myVar1, myVar2, myVar3 );

 

}

 

To Retrieve a Single Value

 

function main() {

 

       ...

       ...

       myVar = middleDonchian( 10 );

 

       //do something with the value in myVar

 

}

 

Calling Examples

 

       //create a study that uses IBM as the symbol along with whatever bar

       //interval you are using in the chart where the script is loaded

       myStudy = upperDonchian( 20, sym( "IBM") );

 

       //create a study that uses the 15-min bar interval, regardless of the bar 

       //interval of the chart in which the script is loaded

       myStudy = middleDonchian( 10, inv(15) );

 

       //create a study that uses the Daily bar interval, regardless of the bar 

       //interval of the chart in which the script is loaded

       myStudy = lowerDonchian( 5, inv("D") );

 

       //create a study that will be based on MSFT 30-min bars, regardless of

       //the symbol/bar interval of the chart in which the script is loaded

       myStudy = middleDonchian( 14, sym( "MSFT,30" ) );

 

       //create a study that will be based on the high.

       myStudy = lowerDonchian( 15, high() );

 

       //create a study that will be based on the close, using 15-min bars, regardless of 

       //the bar interval of the chart in which the script is loaded

       myStudy = middleDonchian( 20, close( inv(15) ) );

 

offsetSeries()