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

#include <indicators.h>

Inheritance diagram for tzu::MACD:
tzu::Indicator< MACD, double, MACDResult >

Public Member Functions

 MACD (size_t short_period, size_t long_period, size_t signal_period, double smoothing=2.0)
MACDResult get () const noexcept
MACDResult update (double value)
Public Member Functions inherited from tzu::Indicator< MACD, double, MACDResult >
MACDResult get () const noexcept
MACDResult update (double value)

Detailed Description

Moving Average Convergence Divergence (MACD)

Combines multiple EMAs to calculate the MACD line, signal line, and histogram. Returns NaN for all values until enough data has been added to fill the initial periods for both EMAs. Once the initial periods are filled, it calculates the MACD line as the difference between the short-term EMA and the long-term EMA. The signal line is calculated as the EMA of the MACD line, and the histogram is the difference between the MACD line and the signal line.

Constructor & Destructor Documentation

◆ MACD()

tzu::MACD::MACD ( size_t short_period,
size_t long_period,
size_t signal_period,
double smoothing = 2.0 )
inline

Member Function Documentation

◆ get()

MACDResult tzu::MACD::get ( ) const
inlinenoexcept

◆ update()

MACDResult tzu::MACD::update ( double value)
inline

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