Signature | Description | Parameters |
---|---|---|
#include <DataFrame/DataFrameFinancialVisitors.h> template<typename T, typename I = unsigned long, std::size_t A = 0> struct VertHorizFilterVisitor; // ------------------------------------- template<typename T, typename I = unsigned long, std::size_t A = 0> using vhf_v = VertHorizFilterVisitor<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 Vertical Horizontal Filter (VHF) indicator. It requires 1 input column. The result is a vector of values with same number of items as the given column. The first period items, in the result, will be NAN. In 1991, Adam White developed the Vertical Horizontal Filter indicator. Traders can use this indicator in technical analysis to recognize periods when the price is trending (up-trend or downtrend) or this indicator is in the congestion phase (side-way trend). This was first published in a magazine called “Issues of Futures”. Traders use the indicator to find out the Phase of a Price Trend. explicit VertHorizFilterVisitor(size_t period = 28) period: Number of periods |
T: Column data type I: Index type A: Memory alignment boundary for vectors. Default is system default alignment |
static void test_VertHorizFilterVisitor() { std::cout << "\nTesting VertHorizFilterVisitor{ } ..." << std::endl; typedef StdDataFrame<std::string> StrDataFrame; StrDataFrame df; try { df.read("data/SHORT_IBM.csv", io_format::csv2); vhf_v<double, std::string> vhf; df.single_act_visit<double>("IBM_Close", vhf); assert(vhf.get_result().size() == 1721); assert(std::isnan(vhf.get_result()[0])); assert(std::isnan(vhf.get_result()[27])); assert(std::abs(vhf.get_result()[28] - 0.385992) < 0.000001); assert(std::abs(vhf.get_result()[30] - 0.371847) < 0.000001); assert(std::abs(vhf.get_result()[35] - 0.417574) < 0.000001); assert(std::abs(vhf.get_result()[1720] - 0.450244) < 0.00001); assert(std::abs(vhf.get_result()[1712] - 0.301387) < 0.000001); assert(std::abs(vhf.get_result()[1707] - 0.297249) < 0.000001); } catch (const DataFrameError &ex) { std::cout << ex.what() << std::endl; } }