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

#include <strategies.h>

Public Member Functions

 MACDStrat (size_t short_period, size_t long_period, size_t signal_period, double smoothing=2.0, double threshold=0.0)
Signal update (const SingleValue &data)

Detailed Description

The MACD strategy generates buy signals when the MACD line crosses above the signal line and sell signals when it crosses below. The threshold parameter allows for a percentage-based buffer to avoid false signals in choppy markets. The strategy keeps track of the last signal to avoid generating multiple buy or sell signals in a row without an intervening signal of the opposite type. The threshold is applied as a percentage difference between the MACD line and the signal line to determine when a crossover is significant enough to generate a signal, helping to filter out noise in volatile markets.

Constructor & Destructor Documentation

◆ MACDStrat()

tzu::MACDStrat::MACDStrat ( size_t short_period,
size_t long_period,
size_t signal_period,
double smoothing = 2.0,
double threshold = 0.0 )
inline

Member Function Documentation

◆ update()

Signal tzu::MACDStrat::update ( const SingleValue & data)
inline

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