mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-28 01:37:43 +00:00
1.4 KiB
1.4 KiB
The Math Behind TEMA
Components of TEMA
TEMA is composed of three main components:
- Exponential Moving Average (EMA)
- A "triple smoothing" factor
Let's break these down:
EMA Calculation
The Exponential Moving Average (EMA) is calculated as:
EMA_t = \alpha \cdot P_t + (1 - \alpha) \cdot EMA_{t-1}
Where:
EMA_tis the EMA value at timetP_tis the price at timet\alphais the smoothing factor, calculated as\frac{2}{n+1}nis the number of periods
TEMA Formula
The TEMA is then calculated using the following formula:
TEMA_t = 3 \cdot EMA_t - 3 \cdot EMA(EMA_t) + EMA(EMA(EMA_t))
Where:
TEMA_tis the TEMA value at timetEMA_tis the EMA of the priceEMA(EMA_t)is the EMA of the EMAEMA(EMA(EMA_t))is the EMA of the EMA of the EMA
Calculation Process
- Calculate the EMA of the price series (EMA1).
- Calculate another EMA on the result of step 1 (EMA2).
- Calculate a third EMA on the result of step 2 (EMA3).
- Multiply EMA1 by 3.
- Multiply EMA2 by 3.
- Subtract EMA2 * 3 from EMA1 * 3.
- Add EMA3 to the result.
This process effectively reduces lag while maintaining smoothness and attempting to minimize overshooting.
Parameter
TEMA uses a single parameter:
- Period (
n): Determines the number of periods used in the EMA calculations. This affects the overall reactivity and smoothness of the indicator.