Smoothed RSI Diff

ICE Data Services -

SmoothedRSI_Diff.efs                                                                                  EFSLibrary - Discussion Board

File Name: SmoothedRSI_Diff.efs


Description:
Smoothed RSI Diff

 

Formula Parameters:
Length RSI1 : 14
Length RSI2 : 28

 

Notes:

Download File:
SmoothedRSI_Diff.efs




EFS 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:        
    Smoothed RSI Diff
    
Version:            1.0  11/03/2009
 
Formula Parameters:                     Default:
    Length RSI1                         14
    Length RSI2                         28
    
Notes:
    
**********************************/
var fpArray = new Array();
var bInit = false;

function preMain(){
    setPriceStudy(false);
    setShowCursorLabel(true);
    setShowTitleParameters(false);
    setStudyTitle("Smoothed RSI Diff");
    setCursorLabelName("RSI Diff", 0);
    setPlotType(PLOTTYPE_LINE, 0);
    setDefaultBarFgColor(Color.green, 0);
    var x = 0;
    fpArray[x] = new FunctionParameter("LengthRSI1", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(14);
    }    
    fpArray[x] = new FunctionParameter("LengthRSI2", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(28);
    }        
}

var xRSI_Diff = null;

function main(LengthRSI1, LengthRSI2) {
var nBarState = getBarState();
var nRSI_Diff = 0;    
    if (nBarState == BARSTATE_ALLBARS) {
        if(LengthRSI1 == null) LengthRSI1 = 14;
        if(LengthRSI1 == null) LengthRSI1 = 28;
	}
	if (bInit == false) {
        xRSI_Diff = efsInternal("Calc_RSI_Diff", LengthRSI1, LengthRSI2);
        addBand(0, PS_SOLID, 1, Color.black, "Zero");	
        bInit = true;
	}
	nRSI_Diff = xRSI_Diff.getValue(0);
    if (nRSI_Diff == null) return;
    return nRSI_Diff;
}

var bSecondInit = false;
var xMARSI_Diff = null;

function Calc_RSI_Diff(LengthRSI1, LengthRSI2) {
var nRes = 0;
var nMARSI_Diff = 0;
	if (bSecondInit == false) {
        xMARSI_Diff = sma(LengthRSI1, efsInternal("Calc_RSI", LengthRSI1, LengthRSI2))
        bSecondInit = true;
	}
	nMARSI_Diff = xMARSI_Diff.getValue(0);
	if (nMARSI_Diff == null) return;
    return nMARSI_Diff;
}

var xRSI1 = null;
var xRSI2 = null;
var bThirdInit = false;

function Calc_RSI(LengthRSI1, LengthRSI2) {
var nRes = 0;
var nRSI1 = 0;
var nRSI2 = 0;
	if (bThirdInit == false) {
        xRSI1 = rsi(LengthRSI1);
        xRSI2 = rsi(LengthRSI2);
        bThirdInit = true;
	}
	nRSI1 = xRSI1.getValue(0);
	nRSI2 = xRSI2.getValue(0);
	if (nRSI1 == null || nRSI2 == null) return;
	nRes = nRSI1 - nRSI2;
	return nRes;
}