#include #include #include "ts.h" bool ts_test_cci( void ) { fp_t const o[] = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; fp_t const h[] = { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 }; fp_t const l[] = { 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }; fp_t const c[] = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; fp_t const * const x[] = { o, h, l, c }; /* k=3 * TP: 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 * SMA(3) of TP: 12, 13, 14, 15, 16, 17, 18, 19 * MAD(3) of TP around SMA: |11-12|+|12-12|+|13-12| / 3 = 2/3 for first window * CCI = (13 - 12) / (0.015 * 2/3) = 1 / 0.01 = 100 * Next: SMA=13, MAD = (|12-13|+|13-13|+|14-13|)/3 = 2/3, CCI = (14-13)/(0.015*2/3) = 100 */ fp_t const e[] = { 100, 100, 100, 100, 100, 100, 100, 100 }; fp_t const * const exp[1] = { e }; uint_t k = 3; return ts_test(ts_cci, ts_cci_offset, x, exp, sizeof( o ) / sizeof( *o ), (ts_constant_t *)&k, &ts_cci_p); }