/***************************************Provided By : eSignal (Copyright ) eSignal), a division of Interactive Data Corporation. 2007. 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: Tandem Studies On Market Movement by Dima VonkoVersion 1.0 8/6/2007Notes:* Study requires version 8.0 or later.Formula Parameters: Default:Color blueThickness 2***************************************/function preMain() { setStudyTitle("Accumulated Range Ratio Bull "); setShowTitleParameters(false); setCursorLabelName("ARRB", 0); var fp1 = new FunctionParameter("cColor", FunctionParameter.COLOR); fp1.setName("Color"); fp1.setDefault(Color.blue); var fp2 = new FunctionParameter("nThick", FunctionParameter.NUMBER); fp2.setName("Thickness"); fp2.setLowerLimit(1); fp2.setDefault(2);}// Global Variablesvar bVersion = null; // Version flagvar bInit = false; // Initialization flag// globals for PrimaryPhaseValue calculation:var xPrimary = null;var firstBarLow = null;var nPsum = 0;var nPsum_1 = 0;// globals for SecondaryPhaseValue calculation:var xSecondary = null;var firstBarHigh = null;var nSsum = 0;var nSsum_1 = 0;function main(cColor, nThick) { if (bVersion == null) bVersion = verify(); if (bVersion == false) return; //Initialization if (bInit == false) { setDefaultBarFgColor(cColor, 0); setDefaultBarThickness(nThick, 0); xPrimary = efsInternal("calcP"); xSecondary = efsInternal("calcS"); bInit = true; } var nPrimaryPhase = xPrimary.getValue(0); var nSecondaryPhase = xSecondary.getValue(0); if (nPrimaryPhase == null || nSecondaryPhase == null) return; // AccumulatedRangeRatioBull var nARRB = nSecondaryPhase / nPrimaryPhase; return nARRB*100;}function calcP() { if (getCurrentBarCount() == 1) { firstBarLow = low(0); nPsum = high(0) - firstBarLow; nPsum_1 = nPsum; } else { if (getBarState() == BARSTATE_NEWBAR) { nPsum_1 = nPsum; } firstBarLow = low(-1); nPsum = nPsum_1 + (high(0) - firstBarLow); } return nPsum;}function calcS() { if (getCurrentBarCount() == 1) { firstBarHigh = high(0); nSsum = firstBarHigh - low(0); nSsum_1 = nSsum; } else { if (getBarState() == BARSTATE_NEWBAR) { nSsum_1 = nSsum; } firstBarHigh = high(-1); nSsum = nSsum_1 + (firstBarHigh - low(0)); } return nSsum;}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;} |