/********************************************************* Alexis C. Montenegro © June 2006 Use and/or modify this code freely. If you redistribute it please include this and/or any other comment block and a description of any changes made. **********************************************************/ // NOTE: // This efs requires amFunctions.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("Linear Regression Slope"); setCursorLabelName("LRS"); setDefaultBarFgColor(Color.blue); setDefaultBarThickness(1); var x=0; fpArray[x] = new FunctionParameter("Length", 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 amLib = addLibrary("amFunctions.efsLib"); var bInit = false; var xLRS = null; function main(Length,Source,Symbol,Interval,Params){ if(bInit==false){ with( amLib ){ if(Symbol == null) Symbol = getSymbol(); if(Interval == null) Interval = getInterval(); var vSymbol = Symbol+","+Interval; xLRS = getSeries(amLinRegSlope(Length,eval(Source)(sym(vSymbol)))); addBand(0,PS_SOLID,1,Color.black,"0"); setShowTitleParameters(eval(Params)); bInit=true; } } return xLRS; }