True Strength Index (TSI)
Install and import#
npm install fintech-algorithmsimport { tsi } from "fintech-algorithms/technical-indicators/momentum/tsi";Signature#
tsi(close, g, s)True strength index: price change smoothed twice, divided by absolute price change smoothed the same way. The double smoothing is what separates it from a plain momentum reading.
Parameters#
| Name | Type | Notes |
|---|---|---|
close | number[] | Per-bar closing prices, chronological. |
g | number | Long smoothing span, applied first. min: 1 · integer: true |
s | number | Short smoothing span, applied to the result of the first pass. min: 1 · integer: true |
Returns#
Record<string, (number | null)[]> · length same-as-input
A single parallel series, tsi.
Warm-up#
The first g + s − 2 positions are null. Both smoothing passes must fill.
Errors#
- When either span is < 1 or is not an integer — throws RangeError
Complexity: time O(n),
space O(n).
Worked example#
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input#
[100, 100.999214, 102.324548, 103.755998, 105.030823, 105.911843]Showing 6 of 120 elements.
Call#
tsi(close, g, s)Returns#
object with 1 field: tsi
{
"tsi": [null, null, null, null, null, null]
}Other exports#
This module also exports
rsi, stochastic, stochasticRsi, williamsR, cci, ultimateOscillator, connorsRsi. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams#
Calculation flow#
Calculation flow
flowchart LR
A["Finalized finalized close"] --> B["Validate order, alignment, and finite values"]
B --> C["Signed / absolute change"]
C --> D["Long EMA"]
D --> E["Short EMA"]
E --> F{"History and denominator valid?"}
F -- "No · short history" --> G["warming-up + reason"]
F -- "No · no finite scale" --> H["undefined + reason"]
F -- "Yes" --> I["Signed-to-magnitude ratio"]
I --> J["ready + aligned component trace"]
How it works#
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References#
- True Strength Index (TSI) — TA-Lib
- Momentum, Direction, and Divergence — William Blau / Wiley
- TA-Lib Technical Analysis Documentation — TA-Lib
- Claim-role ledger
- Evidence boundary