/********************************************************* 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("Fisher"); setCursorLabelName("Fish",0); setCursorLabelName("Sig",1); setDefaultBarFgColor(Color.blue, 0); setDefaultBarFgColor(Color.red, 1); setPlotType(PLOTTYPE_LINE,0); setPlotType(PLOTTYPE_LINE,1); setDefaultBarThickness(1,0); setDefaultBarThickness(1,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("hl2"); } 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 Fish = null; function main(Length,Source,Symbol,Interval,Params){ if(bInit == false){ if(Symbol == null) Symbol = getSymbol(); if(Interval == null) Interval = getInterval(); var vSymbol = Symbol+","+Interval; Fish = getSeries(efsInternal("calcFish",Length,eval(Source)(sym(vSymbol)))); addBand(0, PS_SOLID, 1, Color.black,"0"); setShowTitleParameters(eval(Params)); bInit = true; } return new Array (Fish, Fish.getValue(-1)); } var xValue = 0; var xValue_1 = 0; var xFish = 0; var xFish_1 = 0; var xMaxH = null; var xMinL = null; var xInit = false; function calcFish(length,source){ if (xInit==false){ xMaxH = upperDonchian(length,source); xMinL = lowerDonchian(length,source); xInit=true; } var nMaxH = xMaxH.getValue(0); var nMinL = xMinL.getValue(0); if (nMaxH==null || nMinL == null) return; if (getBarState()==BARSTATE_NEWBAR){ xValue_1 = xValue; xFish_1 = xFish; } if (nMaxH-nMinL!=0){ xValue = 0.33*2*((source.getValue(0)-nMinL)/(nMaxH-nMinL)-0.5)+0.67*xValue_1; } if (xValue > 0.99) xValue = 0.999; if (xValue < -0.99) xValue = -0.999; xFish = 0.5*Math.log((1+xValue)/(1-xValue))+0.5*xFish_1; return (xFish); }