Signature Description Parameters
templat<typename T, typename I = unsigned long, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
struct MACDVisitor;
This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_action_visit() interface.
This functor class calculates the Moving Average Convergence/Divergence oscillator (MACD) which is one of the simplest and most effective momentum indicators available. It could be used to generate signals within financial applications.
The constructor takes:
  • Number of periods for the short-term exponential moving average.
  • Number of periods for the long-term exponential moving average. (short-term EMA – long-term EMA) = MACD Line
  • Number of periods for the signal line. EMA(MACD Line) = Signal Line
  • Decay type for the exponential moving averages.
  • Decay value for the exponential moving averages (See DataFrame Types and Exponential Roll Adopter).
        MACDVisitor(size_type short_mean_period,  // e.g. 12-day
                    size_type long_mean_period,   // e.g. 26-day
                    size_type signal_line_period, // e.g.  9-day
                    exponential_decay_spec ed_spec = exponential_decay_spec::span,
                    double expo_decay_value = 0.2)
        
    There are 3 methods that give you the results:
  1. const result_type &get_macd_line() const – Returns vector of MACD Line (See above).
  2. const result_type &get_signal_line() const – Returns vector of Signal Line (See above).
  3. const result_type &get_macd_histogram() const – Returns vector of MACD Histogram. (MACD Line – Signal Line) = MACD Histogram
T: Column data type
I: Index type