1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <math.h>
#include <stddef.h>
#include "ts.h"
bool ts_test_elder_ray( void )
{
/* k=2, EMA alpha=0.5 */
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[] = { 10, 12, 14, 13, 15, 16, 18, 17, 19, 20 };
fp_t const * const x[] = { o, h, l, c };
/* EMA(2): 10, 11, 12.5, 12.75, 13.875, 14.9375, 16.4688, 16.7344, 17.8672, 18.9336 */
/* Bull: 12-10=2, 13-11=2, 14-12.5=1.5, 15-12.75=2.25, 16-13.875=2.125, 17-14.9375=2.0625, 18-16.4688=1.5312, 19-16.7344=2.2656, 20-17.8672=2.1328, 21-18.9336=2.0664 */
/* Bear: 9-10=-1, 10-11=-1, 11-12.5=-1.5, 12-12.75=-0.75, 13-13.875=-0.875, 14-14.9375=-0.9375, 15-16.4688=-1.4688, 16-16.7344=-0.7344, 17-17.8672=-0.8672, 18-18.9336=-0.9336 */
fp_t const eb[] = { 2, 2, 1.5, 2.25, 2.125, 2.0625, 1.53125, 2.265625, 2.1328125, 2.06640625 };
fp_t const ee[] = { -1, -1, -1.5, -0.75, -0.875, -0.9375, -1.46875, -0.734375, -0.8671875, -0.93359375 };
fp_t const * const exp[2] = { eb, ee };
fp_t k = 2;
return ts_test(ts_elder_ray, ts_elder_ray_offset, x, exp, sizeof( o ) / sizeof( *o ), (ts_constant_t *)&k, &ts_elder_ray_p);
}
|