/**************************************************************************************************** Copyright © eSignal, a division of Interactive Data Corporation. 2006. All rights reserved. This sample eSignal Formula Script (EFS) may be modified and saved under a new filename; however, eSignal is no longer responsible for the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release. *****************************************************************************************************/ function preMain() { setPriceStudy(true); /* Set the title that will appear in the study pane */ setStudyTitle("Keltner"); /* Set the label that will appear in the cursor window */ setCursorLabelName("K-Upper", 0); setCursorLabelName("K-Basis", 1); setCursorLabelName("K-Lower", 2); setDefaultBarFgColor(Color.blue, 0); // upper setDefaultBarFgColor(Color.red, 1); // basis setDefaultBarFgColor(Color.blue, 2); // lower var fp1 = new FunctionParameter("nInputLength", FunctionParameter.NUMBER); fp1.setName("Length"); fp1.setLowerLimit(1); fp1.setDefault(10); } var xKeltner = null; function main(nInputLength) { if (xKeltner == null) xKeltner = efsInternal("calcKeltner", nInputLength); var nKupper = getSeries(xKeltner, 0); var nKbasis = getSeries(xKeltner, 1); var nKlower = getSeries(xKeltner, 2); return new Array(nKupper, nKbasis, nKlower); } var xHLC3 = null; function calcKeltner(n) { if(close(-n) == null) return; if (xHLC3 == null) xHLC3 = efsInternal("calcHLC3"); var vHLC3 = 0; var vHminL = 0; for(var i = 0; i < n; i++) { vHLC3 += xHLC3.getValue(-i); vHminL += high(-i) - low(-i); } vHLC3 /= n; vHminL /= n; return new Array(vHLC3 + vHminL, vHLC3, vHLC3 - vHminL); } function calcHLC3() { return (high(0) + low(0) + close(0)) / 3; }