/********************************************************* Alexis C. Montenegro © September 2005 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("Dynamic Zones"); setCursorLabelName("SellZone", 0); setCursorLabelName("RSI", 1); setCursorLabelName("BuyZone", 2); setDefaultBarFgColor(Color.red, 0); setDefaultBarFgColor(Color.blue, 1); setDefaultBarFgColor(Color.red, 2); setPlotType(PLOTTYPE_LINE,0); setPlotType(PLOTTYPE_LINE,1); setPlotType(PLOTTYPE_LINE,2); setDefaultBarThickness(1,0); setDefaultBarThickness(1,1); setDefaultBarThickness(1,2); var x=0; fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("RSI Length"); setLowerLimit(1); setDefault(9); } 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("PeriodS", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Sell Period"); setLowerLimit(1); setDefault(70); } fpArray[x] = new FunctionParameter("PeriodB", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Buy Period"); setLowerLimit(1); setDefault(70); } fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Show Parameters"); setDefault(false); } } var bInit = false; var xRSI = null; var xBandS = null; var xBandB = null; function main(Length,Source,Symbol,Interval,PeriodS,PeriodB,Params){ if(bInit==false){ if(Symbol == null) Symbol = getSymbol(); if(Interval == null) Interval = getInterval(); var vSymbol = Symbol+","+Interval; xRSI = getSeries(rsi(Length,eval(Source)(sym(vSymbol)))); xBandS = getSeries(upperBB(PeriodS,1.3185,xRSI)); if(PeriodS!=PeriodB){ xBandB = getSeries(lowerBB(PeriodB,1.3185,xRSI)); }else{ xBandB = getSeries(lowerBB(PeriodS,1.3185,xRSI)); } setShowTitleParameters(eval(Params)); bInit=true; } return new Array (xBandS,xRSI,xBandB); }