Signature | Description | Parameters |
---|---|---|
#include <DataFrame/DataFrameFinancialVisitors.h> template<typename T, typename I = unsigned long, std::size_t A = 0> struct ChopIndexVisitor; // ------------------------------------- template<typename T, typename I = unsigned long, std::size_t A = 0> using chop_v = ChopIndexVisitor<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 Choppiness Index indicator. It requires 3 input columns in the order of close, high, low. The Choppiness Index (CHOP) is an indicator designed to determine if the market is choppy (trading sideways) or not choppy (trading within a trend in either direction). The Choppiness Index is an example of an indicator that is not directional at all. CHOP is not meant to predict future market direction, it is a metric to be used to for defining the market's trendiness only. A basic understanding of the indicator would be; higher values equal more choppiness, while lower values indicate directional trending. The Choppiness Index was created by Australian commodity trader E.W. Dreiss. As a range-bound oscillator, The Choppiness Index has values that always fall within a certain range. CHOP produces values that operate between 0 and 100. The closer the value is to 100, the higher the choppiness (sideways movement) levels. The closer the value is to 0, the stronger the market is trending (directional movement) explicit ChopIndexVisitor(size_t roll_period = 14, size_t atr_period = 1); atr_period is used to calculate the Average True Range values |
T: Column data type I: Index type A: Memory alignment boundary for vectors. Default is system default alignment |
static void test_ChopIndexVisitor() { std::cout << "\nTesting ChopIndexVisitor{ } ..." << std::endl; StrDataFrame df; try { df.read("data/SHORT_IBM.csv", io_format::csv2); chop_v<double, std::string> chop; df.single_act_visit<double, double, double>("IBM_Close", "IBM_High", "IBM_Low", chop); assert(chop.get_result().size() == 1721); assert(std::isnan(chop.get_result()[0])); assert(std::isnan(chop.get_result()[12])); assert(std::abs(chop.get_result()[20] - 39.3577) < 0.0001); assert(std::abs(chop.get_result()[25] - 31.2701) < 0.0001); assert(std::abs(chop.get_result()[30] - 40.8049) < 0.0001); assert(std::abs(chop.get_result()[1720] - 27.7729) < 0.0001); assert(std::abs(chop.get_result()[1712] - 37.9124) < 0.0001); assert(std::abs(chop.get_result()[1707] - 34.344) < 0.0001); } catch (const DataFrameError &ex) { std::cout << ex.what() << std::endl; } }