Envelope

ICE Data Services -

upperEnv(), middleEnv(), lowerEnv() Built-in Study Functions

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 securitythe more volatile, the larger the percentage.

Syntax
upperEnv(  nLength , bExponential , nPercentage [, Series | sym() | inv() ][, nBarIndex ] )
middleEnv( nLength , bExponential , nPercentage [, Series | sym() | inv() ][, nBarIndex ] )
lowerEnv(  nLength , bExponential , nPercentage [, Series | sym() | inv() ][, nBarIndex ] )

Parameters
Parameter: Description: Default:
nLength Required. Number of periods to use for calculation.

 

n/a bExponential Required. Boolean true or false to use exponential calculations.

 

n/a nPercentage Required. Number expressed as a percentage to determin envelope width (i.e. enter 10 for 10%).

 

n/a Series or
sym() or
inv()
[Optional]  Series Object or function of sym() or inv() to determine symbol/interval source for the study.

 

Chart's sym/inv nBarIndex [Optional]  Bar index of series to retrieve.

 

n/a


Return Value(s)

Returns a Series Object when nBarIndex is not specified.

Returns a single value when nBarIndex is specified.


Notes
Only available in versions 7.9 or later.

Code Examples
Single Line Indicator:
function main() {    return new Array(upperEnv(20, false, 10),                      	          middleEnv(20, false, 10),                      	          lowerEnv(20, false, 10) );}

Single Line Study-on-Study Indicator:
function main() {    return new Array(upperEnv(20, false, 10, hl2()),                      middleEnv(20, false, 10, hl2()),                      lowerEnv(20, false, 10, hl2()) );}

Retrieve single values:
function main() {    var nValue_0 = middleEnv(20, false, 10, 0);  // Current Bar Index    var nValue_1 = middleEnv(20, false, 10, -1); // Prior Bar Index             return new Array(nValue_0, nValue_1);}

Initialize Series Objects:
//global Series Object variablesvar xStudy1 = null;var xStudy2 = null;var xStudy3 = null;function main() {    if (xStudy1 == null) xStudy1 = upperEnv(20, false, 10);    if (xStudy2 == null) xStudy2 = middleEnv(20, false, 10);    if (xStudy3 == null) xStudy3 = lowerEnv(20, false, 10);            // retrieve single values for conditional statements    var nValue1_0 = xStudy1.getValue(0);  // Current Bar Index value    var nValue2_0 = xStudy2.getValue(0);  // Current Bar Index value    var nValue3_0 = xStudy3.getValue(0);  // Current Bar Index value    var nValue1_1 = xStudy1.getValue(-1); // Prior Bar Index value        // Plot Current Bar Index Value        return new Array(nValue1_0, nValue2_0, nValue3_0);  }

Initialize a Series Object based on an external interval:
// global Series Object variablesvar xStudy1 = null;var xStudy2 = null;var xStudy3 = null;var bInit = false;  // Initialization flagfunction main() {    if (bInit == false) {        xStudy1 = upperEnv(20, false, 10, inv(20));   // 20-min interval        xStudy2 = middleEnv(20, false, 10, inv(20));  // 20-min interval        xStudy3 = lowerEnv(20, false, 10, inv(20));   // 20-min interval        bInit = true;    }            // retrieve single values for conditional statements    var nValue1_0 = xStudy1.getValue(0);  // Current Bar Index value    var nValue1_1 = xStudy1.getValue(-1); // Prior Bar Index value            // Synchronized Series plot    return new Array(getSeries(xStudy1),                     getSeries(xStudy2),                     getSeries(xStudy3) );  }


Initialize a Series Object based on an external symbol and interval:
// global Series Object variablesvar xStudy1 = null;var xStudy2 = null;var xStudy3 = null;var bInit = false;  // Initialization flagfunction main() {    if (bInit == false) {        xStudy1 = upperEnv(20, false, 10, sym("IBM,20"));   // IBM 20-min interval        xStudy2 = middleEnv(20, false, 10, sym("IBM,20"));  // IBM 20-min interval        xStudy3 = lowerEnv(20, false, 10, sym("IBM,20"));   // IBM 20-min interval        bInit = true;    }            // retrieve single values for conditional statements    var nValue1_0 = xStudy1.getValue(0);  // Current Bar Index value    var nValue1_1 = xStudy1.getValue(-1); // Prior Bar Index value            // Synchronized Series plot    return new Array(getSeries(xStudy1),                     getSeries(xStudy2),                     getSeries(xStudy3) );  }


See Also
Series Object
getSeries()
Built-in Study Functions
eSignal Forum Search Engine
Help Guides
Tutorials