TII.efs
EFSLibrary - Discussion Board
File Name: TII.efs
Description:
Trend Intensity Index (TII)
Formula Parameters:
- Length TII : 30
- Length MA : 60
- Upper Band : 80
- Lower Band : 20
- Source of TII : Close
Notes:
The Trend Intensity Index indicator is used to indicate the strength of a current trend in the market. The stronger the trend, the more likely the market will continue moving in this direction insetad of changing course.
Download File:
TII.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: Trend Intensity Index Version: 1.0 05/20/2009 Formula Parameters: Default: Length TII 30 Length MA 60 Upper Band 80 Lower Band 20 Source of TII Close Notes: The Trend Intensity Index indicator is used to indicate the strength of a current trend in the market. The stronger the trend, the more likely the market will continue moving in this direction insetad of changing course. **********************************/ var fpArray = new Array(); var bInit = false; function preMain() { setStudyTitle("Trend Intensity Index"); setCursorLabelName("TII"); setShowTitleParameters(false); setStudyMin(-1); setStudyMax(101); var x = 0; fpArray[x] = new FunctionParameter("nLengthMA", FunctionParameter.NUMBER); with(fpArray[x++]) { setName("Length MA"); setLowerLimit(1); setDefault(60); } fpArray[x] = new FunctionParameter("nLengthTII", FunctionParameter.NUMBER); with(fpArray[x++]) { setName("Length TII"); setLowerLimit(1); setDefault(30); } fpArray[x] = new FunctionParameter("UpperBand", FunctionParameter.NUMBER); with(fpArray[x++]) { setName("Upper Band"); setLowerLimit(1); setDefault(80); } fpArray[x] = new FunctionParameter("LowerBand", FunctionParameter.NUMBER); with(fpArray[x++]) { setName("Lower Band"); setLowerLimit(1); setDefault(20); } fpArray[x] = new FunctionParameter("sPrice", FunctionParameter.STRING); with(fpArray[x++]){ setName("Source of TII"); addOption("open"); addOption("high"); addOption("low"); addOption("close"); addOption("hl2"); addOption("hlc3"); addOption("ohlc4"); setDefault("close"); } } var xTII = null; function main(sPrice, nLengthMA, nLengthTII, UpperBand, LowerBand) { var bBarState = getBarState(); var nTII = 0; if (bBarState == BARSTATE_ALLBARS) { if (nLengthMA == null) nLengthMA = 60; if (nLengthTII == null) nLengthTII = 30; if (sPrice == null) sPrice = "close"; if (UpperBand == null) UpperBand = 80; if (LowerBand == null) LowerBand = 20; } if (bInit == false) { addBand(LowerBand, PS_SOLID, 1, Color.red, "Lower Band"); addBand(UpperBand, PS_SOLID, 1, Color.green, "Upper Band"); xTII = efsInternal("Calc_TII", sPrice, nLengthMA, nLengthTII); bInit = true; } nTII = xTII.getValue(0); if (nTII == null) return; return nTII; } var bSecondInit = false; var xMA = null; var xSeries = null; function Calc_TII(sPrice, nLengthMA, nLengthTII) { var nRes = 0; var i = 0; var dSDP = 0; var dSDM = 0; var nValue = 0; var nMA = 0; if (bSecondInit == false) { xSeries = eval(sPrice)(); xMA = sma(nLengthMA, xSeries); bSecondInit = true; } nMA = xMA.getValue(0); if (nMA == null) return; for(i = 0; i < nLengthTII; i++) { nValue = xSeries.getValue(-i); if(nValue > nMA) { dSDP += nValue - nMA; } else if(nValue < nMA) { dSDM += nMA - nValue; } } nRes = (dSDP / (dSDP + dSDM)) * 100; return nRes; }