/********************************************************* Alexis C. Montenegro © March 2006 Use and/or modify this code freely. If you redistribute it please include this and/or any other comment blocks and a description of any changes you make. **********************************************************/ // NOTE: // This efs requires Parabolic.efsLib in the FunctionLibrary folder. // If you do not have this file you can download it at the link below. // http://share.esignal.com/groupcontents.jsp?folder=Formulas-Libraries&groupid=10 var fpArray = new Array(); function preMain(){ setPriceStudy(false); setStudyTitle("Parabolic Osc") setCursorLabelName("ParOsc"); setPlotType(PLOTTYPE_HISTOGRAM); setDefaultBarThickness(2); var x=0; fpArray[x] = new FunctionParameter("AF", FunctionParameter.NUMBER); with(fpArray[x++]){ setLowerLimit(0); setDefault(0.02); } fpArray[x] = new FunctionParameter("AFMax", FunctionParameter.NUMBER); with(fpArray[x++]){ setLowerLimit(0); setDefault(0.2); } fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING); with(fpArray[x++]){ setDefault(); } fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Show Parameters"); setDefault(false); } } var amLib = addLibrary("Parabolic.efsLib"); var bInit = false; var xPAROSC = null; function main(AF,AFMax,Interval,Params){ if(bInit==false){ if(Interval == null) Interval = getInterval(); var vInterval = Interval; xPAROSC = getSeries(efsInternal("calcOsc",AF,AFMax,inv(vInterval))); setShowTitleParameters(eval(Params)); bInit=true; } return xPAROSC; } var xInit = false; var xParabolic = null; var xClose = null; function calcOsc(_af,_afmax,_source){ if(xInit==false){ with ( amLib ){ xParabolic = amParabolic(_af,_afmax); xClose = close() xInit=true; } } var nClose = xClose.getValue(0); var nParabolic = xParabolic.getValue(-1);//see Note below if(nClose==null||nParabolic==null) return; return (nClose-nParabolic); } //Note: //Replace xParabolic.getValue(-1) with xParabolic.getValue(0) //to plot the current value of the Parabolic study