diff options
Diffstat (limited to 'test/stochastic_fast.c')
| -rw-r--r-- | test/stochastic_fast.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/stochastic_fast.c b/test/stochastic_fast.c new file mode 100644 index 0000000..a30380e --- /dev/null +++ b/test/stochastic_fast.c @@ -0,0 +1,23 @@ +#include <math.h> +#include <stddef.h> +#include "ts.h" + +bool ts_test_stochastic_fast( void ) +{ + /* k=3, offset=k+2=5, y_n=5. %K=80 for all bars (range=5, C-LL=4), %D=SMA(3) of %K=80 */ + 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 = 80 for all (HH-LL=5, C-LL=4 => 100*4/5=80), %D = SMA(3) of %K = 80 */ + fp_t const ek[] = { 80, 80, 80, 80, 80 }; + fp_t const ed[] = { 80, 80, 80, 80, 80 }; + + fp_t const * const exp[2] = { ek, ed }; + + uint_t k = 3; + return ts_test(ts_stochastic_fast, ts_stochastic_fast_offset, x, exp, sizeof( o ) / sizeof( *o ), (ts_constant_t *)&k, &ts_stochastic_fast_p); +} |