tzutrader
A composable C++ backtesting library for trading strategies (experimental)
Loading...
Searching...
No Matches
tzu::EMA Class Reference

#include <indicators.h>

Inheritance diagram for tzu::EMA:
tzu::Indicator< EMA, double, double >

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)

Detailed Description

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.

Constructor & Destructor Documentation

◆ EMA()

tzu::EMA::EMA ( size_t period,
double smoothing = 2.0 )
inline

Member Function Documentation

◆ get()

double tzu::EMA::get ( ) const
inlinenoexcept

◆ update()

double tzu::EMA::update ( double value)
inline

The documentation for this class was generated from the following file: