From 13597eff64eed3bca939405141e3e3a5818aa774 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 21 Feb 2018 12:07:18 +0100 Subject: [PATCH] Lests check if all the visible screen is going to be covered by candles --- .vs/AAOlivia-Plotter/v15/.suo | Bin 17920 -> 16896 bytes Candlestick.js | 28 ++++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.vs/AAOlivia-Plotter/v15/.suo b/.vs/AAOlivia-Plotter/v15/.suo index 5758cfb22dec54d107f34532d0b6bf9e601bbdea..40c67a3b57adbc1fafe07bed9f4554021d7647d7 100644 GIT binary patch delta 106 zcmZqZVQgq&oM0f!00ROH41z#5BM|@l|NlQom~pZrhyBKc62?hPIjjnYb}F!JE@b-6 n%(@_dzBrJ{w!uQO6QmvrW&+vVKsFB$Gfx(DY}k=0& delta 145 zcmZo@VQlDOoM0f!!~g{X3=AwlCL<94`~UwxNR)Z9BZvLQgc8O{OgXFqPTWVCHWxDe wW@c@;@aQy<$+p2lG6|#}3T6P=IY2fK5Hn8}bZpyvz}|srlbs@?WHv!%00jab0ssI2 diff --git a/Candlestick.js b/Candlestick.js index b0f54fa14..bb224383b 100644 --- a/Candlestick.js +++ b/Candlestick.js @@ -358,14 +358,14 @@ let dateDiff = rightDate.valueOf() - leftDate.valueOf(); - leftDate = new Date(leftDate.valueOf() - dateDiff * 1.5); - rightDate = new Date(rightDate.valueOf() + dateDiff * 1.5); + let farLeftDate = new Date(leftDate.valueOf() - dateDiff * 1.5); + let farRightDate = new Date(rightDate.valueOf() + dateDiff * 1.5); - let currentDate = new Date(leftDate.valueOf()); + let currentDate = new Date(farLeftDate.valueOf()); candles = []; - while (currentDate.valueOf() <= rightDate.valueOf() + ONE_DAY_IN_MILISECONDS) { + while (currentDate.valueOf() <= farRightDate.valueOf() + ONE_DAY_IN_MILISECONDS) { let stringDate = currentDate.getFullYear() + '-' + pad(currentDate.getMonth() + 1, 2) + '-' + pad(currentDate.getDate(), 2); @@ -390,7 +390,7 @@ if (candle.open < candle.close) { candle.direction = 'up'; } if (candle.open === candle.close) { candle.direction = 'side'; } - if (candle.begin >= leftDate.valueOf() && candle.end <= rightDate.valueOf()) { + if (candle.begin >= farLeftDate.valueOf() && candle.end <= farRightDate.valueOf()) { candles.push(candle); @@ -402,17 +402,21 @@ } } } - } else { - - //setTimeout(recalculateCandlesUsingDailyFiles, 5000); - - console.log("File missing while calculating candles, scheduling a recalculation in 5 seconds."); - - } + } currentDate = new Date(currentDate.valueOf() + ONE_DAY_IN_MILISECONDS); } + /* Lests check if all the visible screen is going to be covered by candles. */ + + if (candles[0].begin > leftDate.valueOf() || candles[candles.length - 1].end > rightDate.valueOf()) { + + //setTimeout(recalculateCandlesUsingDailyFiles, 5000); + + console.log("File missing while calculating candles, scheduling a recalculation in 5 seconds."); + + } + //console.log("Olivia > recalculateCandlesUsingDailyFiles > total candles generated : " + candles.length); }