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

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

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

template<typename T, typename I = unsigned long>
using cmf_v = ChaikinMoneyFlowVisitor<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 Chaikin Money Flow (CMF) indicator. It requires 5 input columns in order of low, high, open, close, volume.
The result is a vector of values with same number of items as the given column.
Chaikin Money Flow (CMF) developed by Marc Chaikin is a volume-weighted average of accumulation and distribution over a specified period. The standard CMF period is 21 days. The principle behind the Chaikin Money Flow is the nearer the closing price is to the high, the more accumulation has taken place. Conversely, the nearer the closing price is to the low, the more distribution has taken place. If the price action consistently closes above the bar's midpoint on increasing volume, the Chaikin Money Flow will be positive. Conversely, if the price action consistently closes below the bar's midpoint on increasing volume, the Chaikin Money Flow will be a negative value.
T: Column data type
I: Index type
static void test_ChaikinMoneyFlowVisitor()  {

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

    typedef StdDataFrame<std::string> StrDataFrame;

    StrDataFrame    df;

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

        cmf_v<double, std::string>  cmf;

        std::future<cmf_v<double, std::string> &>   fut =
            df.single_act_visit_async<double, double, double, double, long>("IBM_Low", "IBM_High", "IBM_Open", "IBM_Close", "IBM_Volume", cmf);

        fut.get();
        assert(cmf.get_result().size() == 1721);
        assert(std::isnan(cmf.get_result()[0]));
        assert(std::isnan(cmf.get_result()[19]));
        assert(std::abs(cmf.get_result()[20] - -0.0404048) < 0.00001);
        assert(std::abs(cmf.get_result()[24] - -0.0674374) < 0.00001);
        assert(std::abs(cmf.get_result()[25] - -0.0201182) < 0.00001);
        assert(std::abs(cmf.get_result()[1720] - -0.195288) < 0.00001);
        assert(std::abs(cmf.get_result()[1712] - -0.175841) < 0.00001);
        assert(std::abs(cmf.get_result()[1707] - -0.0827408) < 0.00001);
    }
    catch (const DataFrameError &ex)  {
        std::cout << ex.what() << std::endl;
    }
}