Ergotic CCI

ICE Data Services -

ErgoticCCI.efs                                                                                                           EFSLibrary - Discussion Board

File Name: ErgoticCCI.efs


Description:
Ergotic CCI

 

Formula Parameters:
Length CCI : 14
pq : 2
pr : 14
ps : 5

 

Notes:

Download File:
ErgoticCCI.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:        
    Ergotic CCI
Version:            1.0  09/17/2009
 
Formula Parameters:                     Default:
    Length CCI                          14
    pq                                  2
    pr                                  14
    ps                                  5
Notes:
    
**********************************/
var fpArray = new Array();
var bInit = false;

function preMain(){
    setPriceStudy(false);
    setShowCursorLabel(true);
    setShowTitleParameters(false);
    setStudyTitle("Ergotic CCI");
    setCursorLabelName("CCI", 0);
    setPlotType(PLOTTYPE_LINE, 0);
    setDefaultBarFgColor(Color.green, 0);
    setCursorLabelName("Ergotic CCI", 1);
    setPlotType(PLOTTYPE_LINE, 1);
    setDefaultBarFgColor(Color.red, 1);
    var x = 0;
    fpArray[x] = new FunctionParameter("pq", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(2);
    }    
    fpArray[x] = new FunctionParameter("pr", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(14);
    }    
    fpArray[x] = new FunctionParameter("ps", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(5);
    }    
    fpArray[x] = new FunctionParameter("LengthCCI", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setName("Length CCI");
        setLowerLimit(1);
        setDefault(14);
    }        
}

var xCCI = null;
var xEMA2MomAbs = null;
var xEMA2Mom = null;

function main(LengthCCI, pq, pr, ps) {
var nBarState = getBarState();
var nEMAMom = 0;
var nEMAMomAbs = 0;
var nCCI = 0;
var nErgoticCCI = 0;
    if (nBarState == BARSTATE_ALLBARS) {
        if(LengthCCI == null) LengthCCI = 14;
        if(pq == null) pq = 2;
        if(pr == null) pr = 14;
        if(ps == null) ps = 5;
	}
	if (bInit == false) {
        addBand(0, PS_SOLID, 1, Color.black, "Zero");
        xCCI = cci(LengthCCI, hlc3());
        xEMA2Mom = ema(ps, ema(pr, ema(pq, mom(1))));
        xEMA2MomAbs = ema(ps, ema(pr, ema(pq, efsInternal("Calc_MomAbs"))));
        bInit = true;
	}
    nEMAMom = xEMA2Mom.getValue(0);
    nEMAMomAbs = xEMA2MomAbs.getValue(0);
    nCCI = xCCI.getValue(0);
    if (nEMAMom == null || nEMAMomAbs == null || nCCI == null) return;
    if (nEMAMomAbs != 0) {
        nErgoticCCI = (450 * nEMAMom) / nEMAMomAbs;
    } else return;
    return new Array(nCCI, nErgoticCCI);
}

var xMom2 = null;
var bSecondInit = false;

function Calc_MomAbs() {
var nRes = 0;
    if (!bSecondInit) {
        xMom2 = mom(1);
        bSecondInit = true;
    }
    nRes = Math.abs(xMom2.getValue(0));
    if (nRes == null) return;
    return nRes;
}