Advance Decline Ratio

ICE Data Services -

AdvanceDeclineRatio.efs  

EFSLibrary - Discussion Board  

File Name: AdvanceDeclineRatio.efs

Description:
Advance Decline Ratio

 

Formula Parameters:

  • Exchange : NYSE

Notes:

 

Download File:
AdvanceDeclineRatio.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:        
    Advance Decline Ratio
    
Version:            1.0  07/06/2009
    
Formula Parameters:                     Default:
    Exchange                            NYSE

Notes:

**********************************/
var fpArray = new Array();
var bInit = false;

function preMain(){
    setPriceStudy(false);
    setStudyTitle("Advance Decline Ratio");
    setCursorLabelName("AdvDecRatio");    
    var x=0;
    fpArray[x] = new FunctionParameter("sExchange", FunctionParameter.STRING);
	with(fpArray[x++]){
        setName("Exchange");
        addOption("NYSE"); 
        addOption("NASDAQ");         
        setDefault("NYSE");
    }
}

var xAdvDecR = null;

function main(sExchange){
var nBarState = getBarState();
    if (nBarState == BARSTATE_ALLBARS) {
        if (sExchange == null) sExchange = "NYSE";
    }
    if(!bInit){
        xAdvDecR = efsInternal("Calc_Ratio", sExchange);
    }
    return xAdvDecR.getValue(0);
}

var xAdvance = null;
var xDecline = null;

function Calc_Ratio(_exchange){
    if(getBarState() == BARSTATE_ALLBARS){
        if(_exchange == "NYSE"){
            xAdvance = close(sym("$ADV"));
            xDecline = close(sym("$DECL"));
        }else if(_exchange == "NASDAQ"){
            xAdvance = close(sym("$ADVQ"));
            xDecline = close(sym("$DECLQ"));
        }
    }
    if(xAdvance.getValue(0) == null||xDecline.getValue(0)==null) return;
    if((xAdvance.getValue(0) != 0 && xDecline.getValue(0)) != 0)
        var Ratio = xAdvance.getValue(0) / xDecline.getValue(0);
    return Ratio;
}