BUG FIX: Calculating over all indicators are present. TP and STOP at ORD

This commit is contained in:
Luis Fernando Molina committed 2019-07-07 22:51:33 +02:00
1 parent 7c93c4d68e
commit 1fb84584d0
1 file changed
+16 -13
+16 -13
View File
@@ -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) {