Files
QuanTAlib/lib/momentum/tsi/Tsi.md
T
Miha Kralj 4ab3a7fb53 doc headers
2026-02-27 07:48:12 -08:00

5.8 KiB
Raw Blame History

TSI: True Strength Index

Property Value
Category Momentum
Inputs Source (close)
Parameters longPeriod (default DefaultLongPeriod), shortPeriod (default DefaultShortPeriod), signalPeriod (default DefaultSignalPeriod)
Outputs Single series (Tsi)
Output range -1 to +1
Warmup 1 bar

TL;DR

  • The True Strength Index (TSI) is a momentum oscillator developed by William Blau that uses double-smoothed exponential moving averages of price mom...
  • Parameterized by longperiod (default defaultlongperiod), shortperiod (default defaultshortperiod), signalperiod (default defaultsignalperiod).
  • Output range: -1 to +1.
  • Requires 1 bar of warmup before first valid output (IsHot = true).
  • Validated against TA-Lib, Skender, and Tulip reference implementations where available.

The True Strength Index (TSI) is a momentum oscillator developed by William Blau that uses double-smoothed exponential moving averages of price momentum to reduce noise and identify trend strength and direction.

Historical Context

William Blau introduced the TSI in his 1995 book "Momentum, Direction, and Divergence." The indicator was designed to provide a smoother momentum measure by applying double exponential smoothing to price changes, reducing the whipsaws common in simpler momentum indicators.

Algorithm and Implementation

1. Momentum Calculation

mom = Price - Price[1]
absMom = |mom|

Price momentum captures the direction and magnitude of price change.

2. Double EMA Smoothing

// First smoothing with long period
smoothedMomLong = EMA(mom, longPeriod)
smoothedAbsMomLong = EMA(absMom, longPeriod)

// Second smoothing with short period
doubleSmoothedMom = EMA(smoothedMomLong, shortPeriod)
doubleSmoothedAbsMom = EMA(smoothedAbsMomLong, shortPeriod)

Double smoothing reduces noise while preserving trend information.

3. TSI Calculation

TSI = 100 × doubleSmoothedMom / doubleSmoothedAbsMom

The ratio normalizes momentum to a percentage scale.

4. Signal Line

Signal = EMA(TSI, signalPeriod)

The signal line provides crossover signals.

Mathematical Formula

Core Formula

TSI = 100 \times \frac{EMA(EMA(Price_t - Price_{t-1}, long), short)}{EMA(EMA(|Price_t - Price_{t-1}|, long), short)}

Signal Line

Signal = EMA(TSI, signalPeriod)

Default Parameters

  • Long Period: 25
  • Short Period: 13
  • Signal Period: 13

Interpretation

Range

  • TSI oscillates between -100 and +100
  • Positive values indicate bullish momentum
  • Negative values indicate bearish momentum

Signals

  • Zero Line Crossover: TSI crossing above zero is bullish; below zero is bearish
  • Signal Line Crossover: TSI crossing above signal is bullish; below is bearish
  • Divergence: Price and TSI moving in opposite directions suggests trend reversal

Overbought/Oversold

  • Commonly used levels: +25/-25 or +30/-30
  • Extreme readings suggest potential reversal

Performance Profile

Operation Count (Streaming Mode)

TSI(long, short, signal) maintains 5 EMA states: two first-pass EMA smoothers (mom + |mom| on longPeriod), two second-pass EMA smoothers (output of first pass on shortPeriod), and one signal EMA. All are scalar FMA operations.

Operation Count Cost (cycles) Subtotal
Price delta (SUB) 1 1 ~1
ABS of delta 1 1 ~1
EMA1 mom (FMA: α_long × delta + decay × prev) 1 4 ~4
EMA1 abs (FMA: α_long × delta + decay × prev) 1
EMA2 mom (FMA: α_short × EMA1_mom + decay × prev) 1 4 ~4
EMA2 abs (FMA: α_short × EMA1_abs + decay × prev) 1 4 ~4
TSI ratio (× 100 + DIV) 2 9 ~18
Signal EMA (FMA: α_sig × TSI + decay × prev) 1 4 ~4
Total 9 ~40 cycles

O(1) per bar. Default WarmupPeriod = longPeriod + shortPeriod + signalPeriod = 51 bars. The division is the dominant cost; Wilder-smoothed variants can replace all EMAs with RMA (same FMA count, slower convergence).

Batch Mode (SIMD Analysis)

Operation Vectorizable? Notes
Price delta series Yes VSUBPD across full input span
ABS series Yes VABSPD — single instruction
First EMA pass (long period) No Recursive IIR; each value depends on previous
Second EMA pass (short period) No Recursive IIR on output of first pass
TSI ratio Yes VMULPD + VDIVPD once both EMA series are computed
Signal EMA No Recursive IIR

All three EMA passes are recursive IIR filters — inherently serial. A batch implementation can vectorize the delta and ABS computation (4 bars/cycle on AVX2) before the scalar EMA sweeps. The ratio and optional signal computation can be vectorized after the EMA passes complete. Net batch speedup for long series (~1000 bars): approximately 1.31.5× over fully scalar.

Validation

Cross-validated against:

  • TradingView's ta.tsi()
  • Stock.Indicators library
  • TA-Lib implementations

Common Pitfalls

  1. Short Warmup: Ensure sufficient warmup period for convergence
  2. Division by Zero: When no price movement, denominator approaches zero
  3. Lag Inherent: Double smoothing introduces lag in trend identification
  4. Parameter Sensitivity: Results vary significantly with period choices

References

  • Blau, William. "Momentum, Direction, and Divergence." Wiley, 1995
  • Blau, William. "True Strength Index." Technical Analysis of Stocks & Commodities, 1991
  • TradingView TSI Documentation