summaryrefslogtreecommitdiffstats
path: root/test/gator_oscillator.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/gator_oscillator.c')
-rw-r--r--test/gator_oscillator.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/gator_oscillator.c b/test/gator_oscillator.c
new file mode 100644
index 0000000..13ae023
--- /dev/null
+++ b/test/gator_oscillator.c
@@ -0,0 +1,24 @@
+#include <math.h>
+#include <stddef.h>
+#include "ts.h"
+
+bool ts_test_gator_oscillator( void )
+{
+ /* Linear prices: 0,1,2,...,24 */
+ fp_t x[25] = { 0 };
+ for ( uint_t i = 0; i < 25; ++i )
+ x[i] = (fp_t)i;
+
+ fp_t const * const inp[1] = { x };
+
+ /* At i=12: SMA(5) of [8..12] = 10, SMA(8) of [5..12] = 8.5, SMA(13) of [0..12] = 6 */
+ /* Upper = |10 - 8.5| = 1.5, Lower = |6 - 8.5| = 2.5 */
+ /* At i=13: SMA(5) of [9..13] = 11, SMA(8) of [6..13] = 9.5, SMA(13) of [1..13] = 7 */
+ /* Upper = |11 - 9.5| = 1.5, Lower = |7 - 9.5| = 2.5 */
+ /* Constant for linear series */
+ fp_t const eu[] = { 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5 };
+ fp_t const el[] = { 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5 };
+ fp_t const * const exp[2] = { eu, el };
+
+ return ts_test(ts_gator_oscillator, ts_gator_oscillator_offset, inp, exp, 25, (ts_constant_t *)NULL, &ts_gator_oscillator_p);
+}