Signature Description Parameters
#include <DataFrame/DataFrameFinancialVisitors.h>

template<typename T, typename I = unsigned long>
struct EBSineWaveVisitor;

// -------------------------------------

template<typename T, typename I = unsigned long>
using ebsw_v = EBSineWaveVisitor<T, I>;
        
This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_act_visit() interface.

This visitor calculates the rolling values of Even Better Sine Wave (EBSW) indicator.
The result is a vector of values with same number of items as the given column. The first period, in the result, will be NAN.

The Even Better Sinewave Indicator was created by John Ehlers (Cycle Analytics For Traders pgs 161-162) and this indicator works well when the stock is in a trend mode. It will let you know how long to stay with a trade and it works best with a trend confirmation but it can also work on it's own fairly well. Buy when the indicator line is green and sell when it is red.
Positive values in the result vector signal a buy and negative values signal a sell.

    explicit
    EBSineWaveVisitor(std::size_t high_pass_period = 40,
                      std::size_t bar_period = 10);
        
T: Column data type
I: Index type
static void test_EBSineWaveVisitor()  {

    std::cout << "\nTesting EBSineWaveVisitor{  } ..." << std::endl;

    typedef StdDataFrame<std::string> StrDataFrame;

    StrDataFrame    df;

    try  {
        df.read("data/SHORT_IBM.csv", io_format::csv2);

        EBSineWaveVisitor<double, std::string>  ebsw_v;

        df.single_act_visit<double>("IBM_Close", ebsw_v);

        assert(ebsw_v.get_result().size() == 1721);
        assert(std::isnan(ebsw_v.get_result()[0]));
        assert(std::abs(ebsw_v.get_result()[5] - 0.927837) < 0.00001);
        assert(std::abs(ebsw_v.get_result()[14] - -0.560866) < 0.00001);
        assert(std::abs(ebsw_v.get_result()[25] - -0.36883) < 0.00001);
        assert(std::abs(ebsw_v.get_result()[1720] - -0.901317) < 0.00001);
        assert(std::abs(ebsw_v.get_result()[1712] - -0.730321) < 0.00001);
        assert(std::abs(ebsw_v.get_result()[1707] - 0.841759) < 0.00001);
    }
    catch (const DataFrameError &ex)  {
        std::cout << ex.what() << std::endl;
    }
}