RSI_w_Bands.efs

ICE Data Services -

RSI_w_Bands.efs    

File Name: RSI_w_Bands.efs

Description:
Displays RSI with Bollinger Bands appliedto the RSI study.

Formula Parameters:

  • nRSILength - Length of RSI (Default: 14)
  • nRSISource - Source for RSI (Default: "Close")
  • nBandLength - Length of Bollinger Bands (Default: 50)
  • nStdDev - Standard Deviations for BB (Default: 2.1)

Notes:
Valid inputs for nRSISource: Open, High, Low, Close, HL/2, HLC/3 and OHLC/4

Download File:
RSI_w_Bands.efs


EFS Code:

/************************
Copyright © eSignal, 2003
*************************

Description: Displays RSI with Bollinger Bands applied
to the RSI study.

Inputs:
nRSILength - Length of RSI (Default: 14)
nRSISource - Source for RSI (Default: "Close")
nBandLength - Length of Bollinger Bands (Default: 50)
nStdDev - Standard Deviations for BB (Default: 2.1)

*/

var study = null;
var study2 = null;

function preMain() {
    
    setStudyTitle("RSI w/ Bands");
    setCursorLabelName("Upper",0);
    setCursorLabelName("Basis",1);
    setCursorLabelName("Lower",2);
    setCursorLabelName("RSI",3);    
    
    setDefaultBarFgColor(Color.blue,0);
    setDefaultBarFgColor(Color.red,1);
    setDefaultBarFgColor(Color.blue,2);
    setDefaultBarFgColor(Color.aqua,3);
}

function main(nRSILength,nRSISource,nBandLength,nStdDev) {

    if (nRSILength == null) nRSILength = 14;
    if (nRSISource == null) nRSISource = verifySource(nRSISource);
    if (nBandLength == null) nBandLength = 50;
    if (nStdDev == null) nStdDev = 2.1;

    if (study == null) study = new RSIStudy(nRSILength, nRSISource);
    if (study2 == null) study2 = new BollingerStudy(nBandLength, study, RSIStudy.RSI, nStdDev)

    var vRSI   = study.getValue(RSIStudy.RSI);
    var vUpper = study2.getValue(BollingerStudy.UPPER);
    var vBasis = study2.getValue(BollingerStudy.BASIS);
    var vLower = study2.getValue(BollingerStudy.LOWER);
    
    
    return new Array(vUpper, vBasis, vLower, vRSI);
}

/*** Utility Function ***/
// Verifies source input and returns valid source


function verifySource(nSource) {
    
    if (nSource == "close" || nSource =="C" || 
        nSource =="Close" || nSource =="c") {
            nSource = "Close";
            
    } else if (nSource == "open" || nSource =="O" || 
        nSource =="Open" || nSource =="o") {
            nSource = "Open";
            
    } else if (nSource == "high" || nSource =="H" || 
        nSource == "High" || nSource == "h") {
            nSource = "High";
            
    } else if (nSource == "low" || nSource =="L" || 
        nSource =="Low" || nSource =="l") {
            nSource = "Low";
            
    } else if (nSource == "hl/2" || nSource =="HL2" || 
        nSource =="HL/2" || nSource =="hl2") {
            nSource = "HL/2";
            
    } else if (nSource == "hlc/3" || nSource =="hlc3" || 
        nSource =="HLC/3" || nSource =="HLC3") {
            nSource = "HLC/3";
            
    } else if (nSource == "ohlc/4" || nSource =="ohlc4" || 
        nSource =="OHLC/4" || nSource =="OHLC4") {
            nSource = "OHLC/4";
            
    } else {
            nSource = "Close";
    }
    
    return nSource;
}