Quick Search
»

# Trend Intensity Index (TII)

### Syntax

`DataSeries TII( DataSeries ds, int period, int ma_period )`

### Parameter Description

 ds Data series period The number of bars to use when calculating the indicator ma_period The length of the moving average to use

### Description

TII is the Trend Intensity Index. It measures the strength of a trend by tabulating the deviation of price and its moving average. Specify the number of bars to use when calculating the indicator in the Period parameter, and the length of the moving average to use in the MAPeriod parameter.

### Interpretation

TII moves between 0 and 100. A strong uptrend is indicated when TII is above 80. A strong downtrend is indicated when TII is below 20.

### Calculation

TII compares the price to its "MAPeriod" moving average, recording the deviation at each bar. If price is above the moving average, a positive deviation is recorded, and if price is below the moving average a negative deviation. The deviation is simply the distance between price and the moving average.

Once the deviations are calculated, TII is calculated as:

( Sum of Positive Dev ) / ( ( Sum of Positive Dev ) + ( Sum of Negative Dev ) ) * 100

### Example

The following example illustrates how to build a system on TII crosses above and below its threshold levels:

```
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Indicators;namespace WealthLab.Strategies
{
public class TII_Strategy : WealthScript
{
protected override void Execute()
{
TII tii = TII.Series( Close,30,60 );
ChartPane tiiPane = CreatePane( 30,true,true );
PlotSeries( tiiPane, tii, Color.Blue, LineStyle.Solid, 2 );
DrawHorzLine( tiiPane, 20.0, Color.Red, LineStyle.Dashed, 1 );
DrawHorzLine( tiiPane, 80.0, Color.Blue, LineStyle.Dashed, 1 );

for(int bar = 60; bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
Position p = LastPosition;
if ( bar+1 - p.EntryBar >= 10 )
ExitAtMarket( bar+1, p, "Exit after 10 days" );
}
else
{
// Buy when TII crosses above 80
if( CrossOver( bar, tii, 80.0 ) )
BuyAtMarket( bar + 1, "tiiTurnedUp" );					// Short when TII crosses below 20
if( CrossUnder( bar, tii, 20.0 ) )
ShortAtMarket( bar + 1, "tiiTurnedDown" );
}
}
}
}
}
```
 Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.

ScrewTurn Wiki. Some of the icons created by FamFamFam.