|
tzutrader
A composable C++ backtesting library for trading strategies (experimental)
|
#include <indicators.h>
Public Member Functions | |
| EMA (size_t period, double smoothing=2.0) | |
| double | get () const noexcept |
| double | update (double value) |
| Public Member Functions inherited from tzu::Indicator< EMA, double, double > | |
| double | get () const noexcept |
| double | update (double value) |
Exponential Moving Average (EMA)
Uses a smoothing factor to give more weight to recent values. Returns NaN until enough values have been added to fill the initial period. Once the initial period is filled, it calculates the EMA using the formula:
EMA_today = (Value_today * alpha) + (EMA_yesterday * (1 - alpha))
where alpha is the smoothing factor calculated as:
alpha = smoothing / (period + 1)
The default smoothing factor is 2.0, which is commonly used in financial applications.
|
inline |
|
inlinenoexcept |
|
inline |