2025-12-17 09:07:23 +01:00
# True Strength Index (TSI) Indicator Family
## 1. Summary (Introduction)
2025-12-20 23:22:06 +01:00
The True Strength Index (TSI), developed by William Blau, is a momentum oscillator designed to provide a smoother and more reliable measure of market momentum.
2025-12-17 09:07:23 +01:00
Our professional implementation is an **indicator family** consisting of two versions, both powered by a single, universal calculation engine:
* **`TSI_Pro` :** The classic implementation, displaying the main TSI line and a signal line.
* **`TSI_Oscillator_Pro` :** A histogram version that displays the difference between the TSI and its signal line, providing a clearer view of momentum acceleration/deceleration.
2025-12-20 23:22:06 +01:00
**Pro Features:** Both indicators support calculations based on either **standard** or **Heikin Ashi** price data, and offer unprecedented customization by allowing traders to replace the standard EMAs with other smoothing methods (like SMA, DEMA, or TEMA) for every step of the calculation.
2025-12-17 09:07:23 +01:00
## 2. Mathematical Foundations and Calculation Logic
The TSI is calculated by double-smoothing both the price momentum and the absolute price momentum, and then computing their ratio.
### Required Components
2025-12-20 23:22:06 +01:00
* **Slow Period (N_slow):** The period for the first, longer-term smoothing (standard is 25).
* **Fast Period (N_fast):** The period for the second, shorter-term smoothing (standard is 13).
2025-12-17 09:07:23 +01:00
* **Signal Period:** The period for the moving average signal line.
* **Source Price (P):** The price series used for the calculation.
### Calculation Steps (Algorithm)
1. **Calculate Price Momentum:** $\text{Momentum}_i = P_i - P_{i-1}$
2025-12-20 23:22:06 +01:00
2. **First Smoothing (Slow Period):** Apply an `N_slow` -period Moving Average to both the `Momentum` and its absolute value.
* *Classic TSI uses EMA here.*
3. **Second Smoothing (Fast Period):** Apply an `N_fast` -period Moving Average to the results of the first smoothing step.
* *Classic TSI uses EMA here.*
2025-12-17 09:07:23 +01:00
4. **Calculate the TSI Value:** Divide the double-smoothed momentum by the double-smoothed absolute momentum and scale the result to 100.
2025-12-20 23:22:06 +01:00
$\text{TSI}_i = 100 \times \frac{\text{MA}_{\text{fast}}(\text{MA}_{\text{slow}}(\text{Momentum}))_i}{\text{MA}_{\text{fast}}(\text{MA}_{\text{slow}}(\text{AbsMomentum}))_i}$
2025-12-17 09:07:23 +01:00
5. **Calculate the Signal Line:** The signal line is a moving average of the TSI line itself.
2025-12-20 23:22:06 +01:00
2025-12-17 09:07:23 +01:00
6. **Calculate the Oscillator (Histogram):** The difference between the TSI and the Signal Line.
$\text{Oscillator}_i = \text{TSI}_i - \text{Signal}_i$
## 3. MQL5 Implementation Details
Our MQL5 implementation follows a modern, component-based, object-oriented design.
2025-12-20 23:22:06 +01:00
* **Full Engine Integration:**
The core TSI calculator (`TSI_Calculator.mqh` ) is a powerful orchestrator that utilizes **five** instances of our universal `MovingAverage_Engine.mqh` :
1. **Slow Momentum Engine:** Smooths raw momentum.
2. **Fast Momentum Engine:** Double-smooths the result.
3. **Slow Abs Momentum Engine:** Smooths absolute momentum.
4. **Fast Abs Momentum Engine:** Double-smooths the result.
5. **Signal Engine:** Smooths the final TSI line.
This architecture allows for extreme flexibility while maintaining code consistency.
2025-12-17 09:07:23 +01:00
2025-12-20 23:22:06 +01:00
* **Optimized Incremental Calculation (O(1)):**
2025-12-17 09:07:23 +01:00
Unlike basic implementations that recalculate the entire history on every tick, this indicator employs an intelligent incremental algorithm.
2025-12-20 23:22:06 +01:00
* **State Tracking:** It utilizes `prev_calculated` to process only new bars.
* **Persistent Buffers:** Internal buffers persist their state between ticks.
* **Robust Offset Handling:** The engine correctly handles the initialization periods of the chained calculations.
2025-12-17 09:07:23 +01:00
2025-12-20 23:22:06 +01:00
* **Composition Pattern (Oscillator):**
The `TSI_Oscillator_Calculator` uses composition instead of inheritance. It internally owns and manages an instance of the main `CTSICalculator` . This ensures that the Oscillator version uses exactly the same mathematical logic as the Line version, guaranteeing 100% consistency.
2025-12-17 09:07:23 +01:00
## 4. Parameters
2025-12-20 23:22:06 +01:00
* **TSI Calculation Settings:**
* `InpSlowPeriod` : The period for the first smoothing step. (Default: `25` ).
* `InpSlowMAType` : The MA type for the first smoothing. Set to **EMA** for classic TSI behavior. (Default: `EMA` ).
* `InpFastPeriod` : The period for the second smoothing step. (Default: `13` ).
* `InpFastMAType` : The MA type for the second smoothing. Set to **EMA** for classic TSI behavior. (Default: `EMA` ).
* `InpSourcePrice` : The source price for the calculation. (Standard or Heikin Ashi).
2025-12-17 09:07:23 +01:00
* **Signal Line Settings:**
2025-12-20 23:22:06 +01:00
* `InpSignalPeriod` : The lookback period for the signal line. (Default: `13` ).
* `InpSignalMAType` : The type of moving average for the signal line. (Default: `EMA` ).
2025-12-17 09:07:23 +01:00
## 5. Usage and Interpretation
### `TSI_Pro` (Line Chart)
2025-12-20 23:22:06 +01:00
* **Zero Line Crossovers:** A crossover of the TSI line above the zero line indicates that long-term momentum has turned positive.
* **Signal Line Crossovers:** These provide earlier, shorter-term momentum signals.
2025-12-17 09:07:23 +01:00
* **Overbought/Oversold Levels:** The ** +25 and -25** levels are often used to identify extreme momentum.
2025-12-20 23:22:06 +01:00
* **Divergence:** Excellent for spotting divergences between price and momentum.
2025-12-17 09:07:23 +01:00
### `TSI_Oscillator_Pro` (Histogram)
* **Histogram > 0:** The TSI is above its signal line (bullish momentum).
* **Histogram < 0:** The TSI is below its signal line (bearish momentum).
2025-12-20 23:22:06 +01:00
* **Growing Histogram:** Momentum is accelerating.
* **Shrinking Histogram:** Momentum is decelerating (potential reversal warning).