/********************************************************* 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. **********************************************************/ var fpArray = new Array(); function preMain(){ setPriceStudy(false); setStudyTitle("Coppock Curve"); setCursorLabelName("Coppock",0); setDefaultBarFgColor(Color.blue, 0); var x=0; fpArray[x] = new FunctionParameter("Length1", FunctionParameter.NUMBER); with(fpArray[x++]){ setLowerLimit(1); setDefault(11); } fpArray[x] = new FunctionParameter("Length2", FunctionParameter.NUMBER); with(fpArray[x++]){ setLowerLimit(1); setDefault(14); } fpArray[x] = new FunctionParameter("Smooth", FunctionParameter.NUMBER); with(fpArray[x++]){ setLowerLimit(1); setDefault(10); } fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING); with(fpArray[x++]){ addOption("open"); addOption("high"); addOption("low"); addOption("close"); addOption("hl2"); addOption("hlc3"); addOption("ohlc4"); setDefault("close"); } fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING); with(fpArray[x++]){ setDefault(); } 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 bInit = false; var xCoppock = null; function main(Length1,Length2,Smooth,Source,Symbol,Interval,Params){ if(bInit==false){ if(Symbol == null) Symbol = getSymbol(); if(Interval == null) Interval = getInterval(); var vSymbol = Symbol+","+Interval; xCoppock = getSeries(wma(Smooth,efsInternal("calc",Length1,Length2,eval(Source)(sym(vSymbol))))); addBand(0,PS_SOLID,1,Color.black,"0"); setShowTitleParameters(eval(Params)); bInit = true; } return xCoppock; } var xInit = false; var xROC1 = null; var xROC2 = null; function calc(length1,length2,source){ if(xInit==false){ xROC1 = roc(length1,source); xROC2 = roc(length2,source); xInit = true; } var nROC1 = xROC1.getValue(0); var nROC2 = xROC2.getValue(0); if(nROC1==null || nROC2==null) return; return (nROC1+nROC2); }