File Name: SuperPassband.efs

Description:
The Super Passband Filter by John F. Ehlers

Formula Parameters:

SuperPassband.efs
EMA Short Period: 40
EMA Long Period: 60
RMS Period: 50

Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.

Download File:
SuperPassband.efs

SuperPassband.efs


EFS Code:
PHP Code:
/*********************************
Provided By:  
eSignal (Copyright c eSignal), a division of Interactive Data 
Corporation. 2016. 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:        
    The Super Passband Filter by John F. Ehlers

Version:            1.00  05/05/2016

Formula Parameters:                     Default:
EMA Short Period                        40
EMA Long Period                         60
RMS Period                              50


Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.

**********************************/

var fpArray = new Array();

function 
preMain(){
    
    
setPriceStudy(false);
    
setCursorLabelName("SuperPB"0);
    
setDefaultBarFgColor(Color.RGB(0,148,255), 0);
    
setCursorLabelName("+ RMS"1);
    
setDefaultBarFgColor(Color.RGB(255,155,0), 1);
    
setCursorLabelName("- RMS"2);
    
setDefaultBarFgColor(Color.RGB(255,155,0), 2);
    
    var 
x=0;
    
fpArray[x] = new FunctionParameter("EMAShort"FunctionParameter.NUMBER);
    
with(fpArray[x++]){
        
setName("EMA Short Period");
        
setLowerLimit(1);        
        
setDefault(40);
    }
    
fpArray[x] = new FunctionParameter("EMALong"FunctionParameter.NUMBER);
    
with(fpArray[x++]){
        
setName("EMA Long Period");
        
setLowerLimit(1);        
        
setDefault(60);
    }
    
fpArray[x] = new FunctionParameter("RMSPeriod"FunctionParameter.NUMBER);
    
with(fpArray[x++]){
        
setName("RMS Period");
        
setLowerLimit(1);        
        
setDefault(50);
    }
}

var 
bInit false;
var 
bVersion null;
var 
a1 0;
var 
a2 0;
var 
xClose null;
var 
xPB null;
var 
xRMS null;

function 
main(EMAShortEMALongRMSPeriod) {
    
    if (
bVersion == nullbVersion verify();
    if (
bVersion == false) return;
    
    if(
getBarState() == BARSTATE_ALLBARS){
        
bInit false;
    }
    
    if (
getCurrentBarCount() < EMALong) return;
    
    if (!
bInit){
        
a1 EMAShort;
        
a2 EMALong;
        
xClose close();
        
addBand(0PS_DASH1Color.RGB(96,96,96), 4);
        
xPB efsInternal("Calc_PassBand"xClosea1a2);
        
xRMS efsInternal("Calc_RMS",xPBRMSPeriod);
        
bInit true;
    }

    if (
xPB.getValue(0) == null || xRMS.getValue(0) == null) return;
    
    return [
xPB.getValue(0), xRMS.getValue(0), (-xRMS.getValue(0))];
    
}

function 
Calc_PassBand(Closea1a2){
    
    var 
PB null;
    var 
PB_1 ref(-1);
    var 
PB_2 ref(-2);
    
    
PB = (a1 a2) * Close.getValue(0)  
        + (
a2 * (1-a1) - a1 * (a2)) * Close.getValue(-1
        + ((
a1) + (a2)) * PB_1 - (a1)*(a2) * PB_2;
    
    return 
PB;
}

function 
Calc_RMS(PBPeriod){
    
    var 
RMS null;
    for (var 
0Periodi++){
        
RMS RMS PB.getValue(-i) * PB.getValue(-i);
    }
    
RMS Math.sqrt(RMS Period);

    return 
RMS;
}

function 
verify(){
    
    var 
false;
    if (
getBuildNumber() < 779){
        
        
drawTextAbsolute(535"This study requires version 10.6 or later."
            
Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            
null13"error");
        
drawTextAbsolute(520"Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp"
            
Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            
null13"upgrade");
        return 
b;
    } 
    else
        
true;
    
    return 
b;