FisherTrend.efs EFSLibrary - Discussion Board
File Name: FisherTrend.efs
Description:
Fisher Trend
Formula Parameters:
RangePeriods : 30
PriceSmoothing : 0.3
IndexSmoothing : 0.3
Point : 0.01
Notes:
Download File:
FisherTrend.efs
EFS Code:
/********************************* Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2009. All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only and may be modified and saved under a new file name. eSignal is not responsible for the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release. Description: Fisher Trend Version: 1.0 06/16/2009 Formula Parameters: Default: RangePeriods 30 PriceSmoothing 0.3 IndexSmoothing 0.3 Point 0.01 Notes: **********************************/ var fpArray = new Array(); var bInit = false; function preMain(){ setPriceStudy(false); setShowCursorLabel(true); setShowTitleParameters(false); setStudyTitle("Fisher Trend"); setCursorLabelName("Fisher Trend", 0); setDefaultBarFgColor(Color.black, 0); setPlotType(PLOTTYPE_HISTOGRAM, 0); setDefaultBarThickness(2, 0); var x = 0; fpArray[x] = new FunctionParameter("RangePeriods", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(30); } fpArray[x] = new FunctionParameter("PriceSmoothing", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(0.001); setDefault(0.3); } fpArray[x] = new FunctionParameter("IndexSmoothing", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(0.001); setDefault(0.3); } fpArray[x] = new FunctionParameter("Point", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(0); setDefault(0.01); } } var xFT = null; function main(RangePeriods, PriceSmoothing, IndexSmoothing, Point) { var nBarState = getBarState(); var nFT = 0; if (nBarState == BARSTATE_ALLBARS) { if(RangePeriods == null) RangePeriods = 10; if(PriceSmoothing == null) PriceSmoothing = 0.3; if(IndexSmoothing == null) IndexSmoothing = 0.3; if(Point == null) Point = 0.01; } if (bInit == false) { addBand(0, PS_SOLID, 1, Color.black, "Zero"); xFT = efsInternal("Calc_FT", RangePeriods, PriceSmoothing, IndexSmoothing, Point); bInit = true; } nFT = xFT.getValue(0); if (nFT == null) return; if (nFT > 0) setBarFgColor(Color.green, 0); if (nFT < 0) setBarFgColor(Color.red, 0); return nFT; } var bSecondInit = false; var xSmoothedLocation = null; function Calc_FT(RangePeriods, PriceSmoothing, IndexSmoothing, Point) { var nRes = 0; var nRef = ref(-1); var nFT = 0; var nSmoothedLocation = 0; var nFishIndex = 0; var nSmoothedFish = 0; if (bSecondInit == false) { xSmoothedLocation = efsInternal("Calc_SmoothedLocation", RangePeriods, PriceSmoothing, Point); bSecondInit = true; } nSmoothedLocation = xSmoothedLocation.getValue(0); if (xSmoothedLocation.getValue(-1) == null) return; if (nSmoothedLocation > 0.99) nSmoothedLocation = 0.99; if (nSmoothedLocation < -0.99) nSmoothedLocation = -0.99; if( 1 - nSmoothedLocation != 0) nFishIndex = Math.log((1 + nSmoothedLocation) / (1 - nSmoothedLocation)); nFT = IndexSmoothing * nRef + (1 - IndexSmoothing) * nFishIndex; return nFT; } var bThridInit = false; var xHH = null; var xLL = null; var xHL2 = null; function Calc_SmoothedLocation(RangePeriods, PriceSmoothing, Point) { var nRes = 0; var nRef = ref(-1); var nHH = 0; var nLL = 0; var nHHLLRange = 0; var nMidPrice = 0; var nPriceLocation = 0; if (bSecondInit == false) { xHH = upperDonchian(RangePeriods); xLL = lowerDonchian(RangePeriods); xHL2 = hl2(); bSecondInit = true; } nHH = xHH.getValue(0); nLL = xLL.getValue(0); if (xHH.getValue(-1) == null) return; nMidPrice = xHL2.getValue(0); if (nHH - nLL < 0.1 * Point) nHH = nLL + 0.1 * Point; nHHLLRange = nHH - nLL; if (nHHLLRange != 0) { nPriceLocation = (nMidPrice - nLL) / nHHLLRange; nPriceLocation = 2 * nPriceLocation - 1; } nRes = PriceSmoothing * nRef + (1 - PriceSmoothing) * nPriceLocation; return nRes; }