mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-13 16:18:05 +00:00
1.2 KiB
1.2 KiB
The Math Behind DEMA
Components of DEMA
DEMA is composed of two main components:
- Exponential Moving Average (EMA)
- A "double 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
DEMA Formula
The DEMA is then calculated using the following formula:
DEMA_t = 2 \cdot EMA_t - EMA(EMA_t)
Where:
DEMA_tis the DEMA value at timetEMA_tis the EMA of the priceEMA(EMA_t)is the EMA of the EMA
Calculation Process
- Calculate the EMA of the price series.
- Calculate another EMA on the result of step 1.
- Multiply the first EMA by 2.
- Subtract the second EMA from the result of step 3.
This process effectively reduces lag while maintaining smoothness.
Parameter
DEMA 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.