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

template<typename T, typename I = unsigned long,
         std::size_t A = 0>
struct WilliamPrcRVisitor;

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

template<typename T, typename I = unsigned long,
         std::size_t A = 0>
using willp_v = WilliamPrcRVisitor<T, I, A>;
        
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 Williams %R. It requires 3 input columns in the order of low, high, close.
The result is a vector of values with same number of items as the given columns. The first roll_count items, in the result, will be NAN.
Williams %R, also known as the Williams Percent Range, is a type of momentum indicator that moves between 0 and -100 and measures overbought and oversold levels. The Williams %R may be used to find entry and exit points in the market.
    explicit
    WilliamPrcRVisitor(size_t roll_count = 14);
        
T: Column data type
I: Index type
A: Memory alignment boundary for vectors. Default is system default alignment
static void test_WilliamPrcRVisitor()  {

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

    typedef StdDataFrame<std::string> StrDataFrame;

    StrDataFrame    df;

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

        WilliamPrcRVisitor<double, std::string> wpr_v;

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

        assert(wpr_v.get_result().size() == 5031);
        assert(std::isnan(wpr_v.get_result()[0]));
        assert(std::isnan(wpr_v.get_result()[12]));
        assert(std::abs(wpr_v.get_result()[14] - -46.0784) < 0.0001);
        assert(std::abs(wpr_v.get_result()[20] - -85.2941) < 0.0001);
        assert(std::abs(wpr_v.get_result()[5030] - -73.2151) < 0.0001);
        assert(std::abs(wpr_v.get_result()[5026] - -98.3939) < 0.0001);
    }
    catch (const DataFrameError &ex)  {
        std::cout << ex.what() << std::endl;
    }
}
C++ DataFrame