Envelope

eSignal EFS 2

Envelope

Top  Previous  Next

 

upperEnv( length, bExponential, percentage [, source | sym() | inv()] [, barIndex] )

middleEnv( length, bExponential, percentage [, source | sym() | inv()] [, barIndex])

lowerEnv( length, bExponential, percentage [, source | sym() | inv()] [, barIndex] )

 

An envelope is composed of two moving averages. One moving average is shifted upward and the second moving average is shifted downward. Envelopes define the upper and lower boundaries of a security's normal trading range. A sell signal is generated when the security reaches the upper band, whereas a buy signal is generated at the lower band. The optimum percentage shift depends on the volatility of the security—the more volatile, the larger the percentage.

 

Parameters

 

length

the period to use for the calculation

 

bExponential

create an exponential average

 

percentage

envelope width expressed as a percentage

 

source

optional. input series for the study

default: close

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 = upperEnv( 20, false, 10 );

               myStudy2 = middleEnv( 20, false, 10 );

               myStudy3 = lowerEnv( 20, false, 10 );

 

               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 = middleEnv( 20, false, 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 = middleEnv( 20, false, 10, 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 = upperEnv( 20, false, 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 = lowerEnv( 10, true, 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 = middleEnv( 12, false, 4, sym( "MSFT,30" ) );

 

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

       myStudy = upperEnv( 10, false, 3, 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 = lowerEnv( 20, true, 7, close( inv(15) ) );

 

offsetSeries()