From 2b34928f8eca91e00fa69f5c9b02b405e73156f3 Mon Sep 17 00:00:00 2001 From: Mike Bryant Date: Fri, 3 Apr 2020 16:28:51 +0100 Subject: [PATCH] Fix the -1s --- js/scripts.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/scripts.js b/js/scripts.js index bbb721b..e555e64 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -452,10 +452,15 @@ function* generate_pattern_3_with_peak(given_prices, peak_start) { }); } - // TODO this could be made more accurate, I've not bothered with the -1s, or forward/backward calculating of the rate each side of the peak value + // TODO this could be made more accurate, I've not bothered with forward/backward calculating of the rate each side of the peak value for (var i = peak_start+2; i < peak_start+5; i++) { - min_pred = Math.floor(1.4 * buy_price); - max_pred = Math.ceil(2.0 * buy_price); + if (i == peak_start+3) { + min_pred = Math.floor(1.4 * buy_price); + max_pred = Math.ceil(2.0 * buy_price); + } else { + min_pred = Math.floor(1.4 * buy_price) - 1; + max_pred = Math.ceil(2.0 * buy_price) - 1; + } if (!isNaN(given_prices[i])) { if (given_prices[i] < min_pred || given_prices[i] > max_pred ) { // Given price is out of predicted range, so this is the wrong pattern