From 1fb84584d06d8b92e01ea31a3a49fd82b0962e1b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 7 Jul 2019 22:51:33 +0200 Subject: [PATCH] BUG FIX: Calculating over all indicators are present. TP and STOP at ORD --- Commons.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Commons.js b/Commons.js index 722388405..9a81744f8 100644 --- a/Commons.js +++ b/Commons.js @@ -343,16 +343,25 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { for (let i = 0; i < candles.length; i++) { /* Update all the data objects available for the simulation. */ - + let candle = candles[i]; let percentageBandwidth = percentageBandwidthMap.get(candle.begin); let bollingerBand = bollingerBandsMap.get(candle.begin); + let bollingerChannel = getElement(bollingerChannelsArray, candle.begin, candle.end); + let bollingerSubChannel = getElement(bollingerSubChannelsArray, candle.begin, candle.end); + //let LRC = LRCMap.get(candle.begin); - //if (LRC === undefined) { continue; } - if (percentageBandwidth === undefined) { continue; } // percentageBandwidth might start after the first few candles. - if (candle.begin < initialDate.valueOf()) { continue; } + /* If any of the needed indicators is missing, then that period is not calculated */ + if (candle.begin < initialDate.valueOf()) { continue; } + if (bollingerBand === undefined) { continue; } + if (percentageBandwidth === undefined) { continue; } // percentageBandwidth might start after the first few candles. + if (bollingerChannel === undefined) { continue; } + if (bollingerSubChannel === undefined) { continue; } + + //if (LRC === undefined) { continue; } + periods++; days = periods * timePeriod / ONE_DAY_IN_MILISECONDS; @@ -362,9 +371,6 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { } } - let bollingerChannel = getElement(bollingerChannelsArray, candle.begin, candle.end); - let bollingerSubChannel = getElement(bollingerSubChannelsArray, candle.begin, candle.end); - let lastObjects = { candle: clone(candle), //LRC: clone(LRC), @@ -1280,6 +1286,9 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { } } + calculateTakeProfit(); + calculateStopLoss(); + marketRate = candle.close; positionRate = candle.close; @@ -1664,12 +1673,6 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { return element } } - - element = { - direction: 'unknown', - slope: 'unknown' - }; - return element; } } catch (err) {