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

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

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

template<typename T, typename I = unsigned long>
using ttmt_v = TTMTrendVisitor<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 Trade To Market trend indicator. It requires 3 input columns in the order of low, high, close.
The result is a vector of boolean values with same number of items as the given columns. The first bar_periods items, in the result, will be false.

TTM Trend indicator is from John Carters book “Mastering the trade” and plots the bars green or red (in this results it would be true or false). It checks if the price is above or under the average price of the previous 5 bars. The indicator should help you stay in a trade until the colors chance. Two bars of the opposite color is the signal to get in or out.
    explicit
    TTMTrendVisitor(std::size_t bar_periods = 5);
        
T: Column data type
I: Index type
static void test_TTMTrendVisitor()  {

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

    typedef StdDataFrame<std::string> StrDataFrame;

    StrDataFrame    df;

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

        TTMTrendVisitor<double, std::string> ttmt_v;

        df.single_act_visit<double, double, double>("IBM_Low", "IBM_High", "IBM_Close", ttmt_v);

        assert(ttmt_v.get_result().size() == 5031);
        assert((! ttmt_v.get_result()[0]));
        assert((! ttmt_v.get_result()[8]));
        assert(ttmt_v.get_result()[9]);
        assert(ttmt_v.get_result()[13]);
        assert((! ttmt_v.get_result()[14]));
        assert(ttmt_v.get_result()[5030]);
        assert((! ttmt_v.get_result()[5027]));
        assert(ttmt_v.get_result()[5016]);
    }
    catch (const DataFrameError &ex)  {
        std::cout << ex.what() << std::endl;
    }
}
C++ DataFrame