/*********************************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: Klinger Volume Oscillator (KVO) Version: 1.0 05/27/2009 Formula Parameters: Default: TrigLen 13 FastX 34 SlowX 55 Notes: The Klinger Oscillator (KO) was developed by Stephen J. Klinger. Learning from prior research on volume by such well-known technicians as Joseph Granville, Larry Williams, and Marc Chaikin, Mr. Klinger set out to develop a volume-based indicator to help in both short- and long-term analysis. The KO was developed with two seemingly opposite goals in mind: to be sensitive enough to signal short-term tops and bottoms, yet accurate enough to reflect the long-term flow of money into and out of a security. The KO is based on the following tenets: Price range (i.e. High - Low) is a measure of movement and volume is the force behind the movement. The sum of High + Low + Close defines a trend. Accumulation occurs when today's sum is greater than the previous day's. Conversely, distribution occurs when today's sum is less than the previous day's. When the sums are equal, the existing trend is maintained. Volume produces continuous intra-day changes in price reflecting buying and selling pressure. The KO quantifies the difference between the number of shares being accumulated and distributed each day as "volume force". A strong, rising volume force should accompany an uptrend and then gradually contract over time during the latter stages of the uptrend and the early stages of the following downtrend. This should be followed by a rising volume force reflecting some accumulation before a bottom develops.**********************************/var fpArray = new Array();var bInit = false;function preMain() { setStudyTitle("Klinger Volume Oscillator"); setCursorLabelName("KVO",0); setCursorLabelName("Trigger",1); setDefaultBarFgColor(Color.red,0); setDefaultBarFgColor(Color.brown,1); addBand(0, PS_SOLID, 1, Color.black); var x = 0; fpArray[x] = new FunctionParameter("TrigLen", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(13); } fpArray[x] = new FunctionParameter("FastX", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(34); } fpArray[x] = new FunctionParameter("SlowX", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(55); } }var xKVO = null;var xTrigger = null;function main(FastX, SlowX, TrigLen){var nBarState = getBarState();var nKVO = 0;var nTrigger = 0; if (nBarState == BARSTATE_ALLBARS) { if(FastX == null) FastX = 34; if(SlowX == null) SlowX = 55; if(TrigLen == null) TrigLen = 13; } if (bInit == false) { xKVO = efsInternal("Calc_KVO", FastX, SlowX); xTrigger = ema(TrigLen, xKVO); bInit = true; } nKVO = xKVO.getValue(0); nTrigger = xTrigger.getValue(0); if (nTrigger == null) return; return new Array(nKVO, nTrigger);}var bSecondInit = false;var xFast = null;var xSlow = null;var xTrend = null;function Calc_KVO(FastX, SlowX) {var nRes = 0;var FXAvg = 0;var SXAvg = 0; if (bSecondInit == false) { xTrend = efsInternal("Calc_Trend"); xFast = ema(FastX, xTrend); xSlow = ema(SlowX, xTrend); bSecondInit = true; } FXAvg = xFast.getValue(0); SXAvg = xSlow.getValue(0); if (SXAvg == null) return; nRes = FXAvg - SXAvg; return nRes;}var xhlc3 = null;function Calc_Trend() {var nRes = 0; if (xhlc3 == null) xhlc3 = hlc3(); if (xhlc3.getValue(-1) == null) return; if(xhlc3.getValue(0) > xhlc3.getValue(-1)) nRes = 1; else nRes = -1; nRes = volume(0) * nRes * 100; return nRes;} |