File Name: HMA_Channels.efs

Description:
HMA Channels

Formula Parameters:
Length : 20
Percentage : 0.5


Notes:


Download File:
HMA_Channels.efs



EFS Code:
PHP Code:
/*********************************
Provided By:  
    eSignal (Copyright c eSignal), a division of Interactive Data 
    Corporation. 2009. All rights reserved. This sample eSignal 
    Formula Script (EFS) is for educational purposes only and may be 
    modified and saved under a new file name.  eSignal is not responsible
    for the functionality once modified.  eSignal reserves the right 
    to modify and overwrite this EFS file with each new release.

Description:        
    HMA Channels
    
Version:            1.0  10/29/2009
 
Formula Parameters:                     Default:
    Length                              20
    Percentage                          0.5
    
Notes:
    
**********************************/
var fpArray = new Array();
var 
bInit false;

function 
preMain(){
    
setPriceStudy(true);
    
setShowCursorLabel(true);
    
setShowTitleParameters(false);
    
setStudyTitle("HMA Channels");
    
setCursorLabelName("Up Band"0);
    
setPlotType(PLOTTYPE_LINE0);
    
setDefaultBarFgColor(Color.red0);
    
setCursorLabelName("Dn Band"1);    
    
setPlotType(PLOTTYPE_LINE1);
    
setDefaultBarFgColor(Color.red1);
    var 
0;
    
fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
    
with(fpArray[x++]) {
        
setLowerLimit(1);
        
setDefault(20);
    }    
    
fpArray[x] = new FunctionParameter("Percentage"FunctionParameter.NUMBER);
    
with(fpArray[x++]) {
        
setLowerLimit(0);
        
setDefault(0.5);
    }        
}

var 
xMAD2 null;
var 
xMA null;

function 
main(LengthPercentage) {
var 
nBarState getBarState();
var 
nUpBand 0;
var 
nDnBand 0;
var 
nMAD2 0;
var 
nMA 0;
    if (
nBarState == BARSTATE_ALLBARS) {
        if(
Length == nullLength 20;
        if(
Percentage == nullPercentage 0.5;
    }
    if (
bInit == false) {
        
xMAD2 wma(Math.round(Length 2), high());
        
xMA wma(Lengthhigh());
        
bInit true;
    }
    
nMAD2 xMAD2.getValue(0);
    
nMA xMA.getValue(0);
    if (
nMAD2 == null || nMA == null) return;
    
nUpBand = (Percentage 100) * nMAD2 nMA;
    
nDnBand = (Percentage 100) * nMAD2 nMA;
    return new Array(
nUpBandnDnBand);