Qualitative Quantitative Estimation

ICE Data Services -

QQE.efs  
EFSLibrary - Discussion Board  

File Name: QQE.efs

Description:
Qualitative Quantitative Estimation

Formula Parameters:

  • RSI Length : 14
  • SF : 5

Notes:

Download File:
QQE.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:        
    Qualitative Quantitative Estimation
    
Version:            1.0  07/19/2009
 
Formula Parameters:                     Default:
    RSI Length                          14
    SF                                  5
    
Notes:
    
**********************************/
var fpArray = new Array();
var bInit = false;

function preMain(){
    setPriceStudy(false);
    setShowCursorLabel(true);
    setShowTitleParameters(false);
    setStudyTitle("Qualitative Quantitative Estimation");
    setCursorLabelName("QQE", 0);
    setDefaultBarFgColor(Color.blue, 0);
    setPlotType(PLOTTYPE_LINE, 0);
    setDefaultBarThickness(2, 0);
    setDefaultBarFgColor(Color.red, 1);
    setPlotType(PLOTTYPE_LINE, 1);
    setDefaultBarThickness(1, 1);
    var x = 0;
    fpArray[x] = new FunctionParameter("RSILength", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setName("RSI Length");
        setLowerLimit(1);
        setDefault(14);
    }    
    fpArray[x] = new FunctionParameter("SF", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(5);
    }        
}

var xTrLevelSlow = null;
var xRSI = null;

function main(RSILength, SF) {
var nBarState = getBarState();
var nTrLevelSlow = 0;
    if (nBarState == BARSTATE_ALLBARS) {
        if(RSILength == null) RSILength = 14;
        if(SF == null) SF = 5;
	}
	if (bInit == false) {
        xTrLevelSlow = efsInternal("Calc_TrLevelSlow", SF, RSILength);
        xRSI = getSeries(xTrLevelSlow, 1);
        bInit = true;
	}
	nTrLevelSlow = xTrLevelSlow.getValue(0)
	if (nTrLevelSlow== null) return;
    return new Array(xRSI.getValue(0), nTrLevelSlow);
}

var bSecondInit = false;
var xMaAtrRsi = null;
var xMARSI = null;
var tr = 0;
var tr1 = 0;

function Calc_TrLevelSlow(SF, RSILength) {
var nBarState = getBarState();
var nRes = 0;
var WildersLength = RSILength * 2 - 1;
    nRes = tr;
	if (bSecondInit == false) {
        xMARSI = efsInternal("Calc_AtrRSI", SF, RSILength);
        xMaAtrRsi = ema(WildersLength, ema(WildersLength , getSeries(xMARSI, 1)));
        bSecondInit = true;
	}
    if (xMaAtrRsi.getValue(-1) == null) return;
    if (nBarState == BARSTATE_NEWBAR) {
        tr1 = tr;
    }
	var rsi0 = xMARSI.getValue(0);
	var rsi1 = xMARSI.getValue(-1);	
	var dar = xMaAtrRsi.getValue(0) * 4.236;
	var dv = tr1;
    if (rsi0 < tr1) {
        tr = rsi0 + dar;
        if (rsi1 < dv) {
            if (tr > dv) {
                tr = dv;
            }    
        }        
        nRes = tr;        
    } else {
        tr = rsi0 - dar;
        if (rsi1 > dv) {
            if (tr < dv) {
                tr = dv;
            }    
        }        
        nRes = tr;
    }
    return new Array(nRes, rsi0);
}

bThreadInit = false;
var xLocalRSI = null;
var xLocalRSIMA = null;

function Calc_AtrRSI(SF, RSILength) {
var nRes = 0;
var nRSI = 0;
var nRSI1 = 0;
    if (bThreadInit == false) {
        xLocalRSI = rsi(RSILength);
        xLocalRSIMA = ema(SF, xLocalRSI);
        bThreadInit = true;
    }    
    nRSI = xLocalRSIMA.getValue(0);
    nRSI1 = xLocalRSIMA.getValue(-1);
    if (nRSI1 == null) return;
    nRes = Math.abs(nRSI1 - nRSI);
    return new Array(nRSI, nRes);
}