/********************************************************* Alexis C. Montenegro © January 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() { setStudyTitle("MAofKST"); setCursorLabelName("KST", 0); setCursorLabelName("MA", 1); setDefaultBarFgColor(Color.blue, 0); setDefaultBarFgColor(Color.red, 1); setDefaultBarThickness(1,0); setDefaultBarThickness(1,1); var x=0; fpArray[x] = new FunctionParameter("KSTPeriod", FunctionParameter.STRING); with(fpArray[x++]){ setName("Period"); addOption("ShortD"); addOption("ShortW"); addOption("IntermediateW"); addOption("LongM"); addOption("LongW"); addOption("Insert parameters here"); setDefault("ShortD"); } fpArray[x] = new FunctionParameter("KSTType", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Exponential Average"); setDefault(false); } fpArray[x] = new FunctionParameter("MAType", FunctionParameter.STRING); with(fpArray[x++]){ addOption("sma"); addOption("ema"); addOption("wma"); setDefault("sma"); } fpArray[x] = new FunctionParameter("MALength", FunctionParameter.NUMBER); with(fpArray[x++]){ setLowerLimit(1); setDefault(3); } 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("amStudies.efsLib"); var bInit = false; var xKST = null; var xMAofKST = null; function main(KSTPeriod,KSTType,MAType,MALength,Source,Symbol,Interval,Params){ if(bInit==false){ with( amLib ) { if(Symbol == null) Symbol = getSymbol(); if(Interval == null) Interval = getInterval(); var vSymbol = Symbol+","+Interval; xKST = getSeries(amKST(KSTPeriod,KSTType,eval(Source)(sym(vSymbol)))); xMAofKST = getSeries(eval(MAType)(MALength,xKST)); addBand(0,PS_SOLID,1,Color.black,"0"); setShowTitleParameters(eval(Params)); bInit=true; } } return new Array (xKST,xMAofKST); }