/*********************************Provided By: Interactive Data Corporation (Copyright 2010) All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only. Interactive Data Corporation reserves the right to modify and overwrite this EFS file with each new release. Description: The Volume Zone Oscillator Version: 1.0 14/03/2011Formula Parameters: Default: Period 14 Notes: The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.**********************************/var fpArray = new Array();var bVersion = null;function preMain(){ setStudyMin(-100); setStudyMax(100); setStudyTitle("Volume Zone Oscillator"); setCursorLabelName("Volume Zone Osc", 0); var x=0; fpArray[x] = new FunctionParameter("gPeriod", FunctionParameter.NUMBER); with(fpArray[x++]) { setName("Period"); setLowerLimit(1); setDefault(14); } fpArray[x] = new FunctionParameter("gLevels", FunctionParameter.BOOLEAN); with(fpArray[x++]) { setName("Show Levels"); setDefault(true); }}var bInit = false;var xVol = null;var xR = null;var xVP = null;var xTV = null;function main(gPeriod, gLevels){ if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if (!bInit) { xVol = volume(); xR = efsInternal("calcSignedVol", xVol, close()); xVP = ema(gPeriod, xR); xTV = ema(gPeriod, xVol); if ( gLevels ) { addBand(60, PS_DOT, 2, Color.green, "lev60"); addBand(40, PS_DASH, 2, Color.darkgreen, "lev40"); addBand(15, PS_SOLID, 1, Color.grey, "lev15"); addBand(0, PS_SOLID, 2, Color.grey, "lev0"); addBand(-5, PS_SOLID, 1, Color.grey, "lev5n"); addBand(-40, PS_DASH, 2, Color.maroon, "lev40n"); addBand(-60, PS_DOT, 2, Color.red, "lev60n"); } bInit = true; } var vVP = xVP.getValue(0); var vTV = xTV.getValue(0); if ( vVP == null ) return null; var vVZO = 100; if ( vTV != 0 ) vVZO = 100 * vVP / vTV; return vVZO; }function calcSignedVol(xVol, xCls){ var vVol = xVol.getValue(0); var vCls1 = xCls.getValue(-1); var vCls0 = xCls.getValue(0); if ( vCls1 == null ) return null; vVol = (vCls1 < vCls0)? vVol : -vVol; return vVol;}function verify() { var b = false; if (getBuildNumber() < 779) { drawTextAbsolute(5, 35, "This study requires version 8.0 or later.", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "error"); drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "upgrade"); return b; } else { b = true; } return b;} |