ChaikinVolatility.efs EFSLibrary - Discussion Board
File Name: ChaikinVolatility.efs
Description:
Chaikin Volatility
Formula Parameters:
Length: 10
ROC Length: 12
Price 1 Data To Use: High
Price 2 Data To Use: Low
Notes:
Chaikin's Volatility indicator compares the spread between a security's
high and low prices. It quantifies volatility as a widening of the range
between the high and the low price.
Download File:
ChaikinVolatility.efs
EFS Code:
/********************************* Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2008. 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: Chaikin Volatility Version: 1.0 11/10/2008 Formula Parameters: Default: Length 10 ROC Length 12 Price 1 Data To Use High Price 2 Data To Use Low Notes: Chaikin's Volatility indicator compares the spread between a security's high and low prices. It quantifies volatility as a widening of the range between the high and the low price. **********************************/ var fpArray = new Array(); var bInit = false; function preMain() { setPriceStudy(false) setStudyTitle("Chaikin Volatility"); setCursorLabelName("Chaikin Volatility", 0); setDefaultBarFgColor(Color.blue, 0); setPlotType(PLOTTYPE_LINE,0); setDefaultBarThickness(1,0); var x=0; fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER); with(fpArray[x++]){ setLowerLimit(1); setDefault(10); } fpArray[x] = new FunctionParameter("ROCLen", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("ROC Length"); setLowerLimit(1); setDefault(12); } fpArray[x] = new FunctionParameter("Price1", FunctionParameter.STRING); with(fpArray[x++]){ setName("Price 1 Data To Use"); addOption("open"); addOption("high"); addOption("low"); addOption("close"); addOption("hl2"); addOption("hlc3"); addOption("ohlc4"); setDefault("high"); } fpArray[x] = new FunctionParameter("Price2", FunctionParameter.STRING); with(fpArray[x++]){ setName("Price 2 Data To Use"); addOption("open"); addOption("high"); addOption("low"); addOption("close"); addOption("hl2"); addOption("hlc3"); addOption("ohlc4"); setDefault("low"); } } var xROC_EMA = null; var xPrice1 = null; var xPrice2 = null; var xPrice = null; function main(Price1, Price2, Length, ROCLen) { var nState = getBarState(); var nROC = 0; if (nState == BARSTATE_ALLBARS) { if (Price1 == null) Price1 = "high"; if (Price2 == null) Price2 = "low"; if (Length == null) Length = 10; if (ROCLen == null) ROCLen = 12; } if ( bInit == false ) { xPrice1 = eval(Price1)(); xPrice2 = eval(Price2)(); xPrice = efsInternal("Calc_Price", xPrice1, xPrice2) xROC_EMA = roc(ROCLen, ema(Length, xPrice)); bInit = true; } if (getCurrentBarCount() < Math.max(Length, ROCLen)) return; nROC = xROC_EMA.getValue(0); return nROC; } function Calc_Price(xPrice1, xPrice2) { var nRes = 0; nRes = xPrice1.getValue(0) - xPrice2.getValue(0); if (nRes == null) nRes = 1; return nRes; }