UpsideDownsideRatio.efs
EFSLibrary - Discussion Board
File Name: UpsideDownsideRatio.efs
Description:
Upside Downside Ratio
Formula Parameters:
- Exchange : NYSE
Notes:
Download File:
UpsideDownsideRatio.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: Upside Downside 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("Upside Downside Ratio"); setCursorLabelName("UpDownRatio"); var x=0; fpArray[x] = new FunctionParameter("sExchange", FunctionParameter.STRING); with(fpArray[x++]){ setName("Exchange"); addOption("NYSE"); addOption("NASDAQ"); setDefault("NYSE"); } } var xUpDownR = null; function main(sExchange){ var nBarState = getBarState(); if (nBarState == BARSTATE_ALLBARS) { if (sExchange == null) sExchange = "NYSE"; } if(!bInit){ xUpDownR = efsInternal("Calc_Ratio", sExchange); } return xUpDownR.getValue(0); } var xAdvance = null; var xDecline = null; function Calc_Ratio(_exchange){ if(getBarState() == BARSTATE_ALLBARS){ if(_exchange == "NYSE"){ xAdvance = close(sym("$UVOL")); xDecline = close(sym("$DVOL")); }else if(_exchange == "NASDAQ"){ xAdvance = close(sym("$UVOLQ")); xDecline = close(sym("$DVOLQ")); } } 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; }