From 68697c728038299ec168974eed0ab066a21f43c2 Mon Sep 17 00:00:00 2001 From: Smidy13 <77650800+Smidy13@users.noreply.github.com> Date: Sat, 5 Jun 2021 16:51:25 +1200 Subject: [PATCH] Bug Fix: Display Error if Trading System Formula Evaluates as Undefined --- .../Low-Frequency-Trading/TradingPosition.js | 4 ++-- .../Low-Frequency-Trading/TradingSystem.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js index d60920629..ee3fb122b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js @@ -148,7 +148,7 @@ exports.newSuperalgosBotModulesTradingPosition = function (processIndex) { function updateStopLossTakeProfitFinalValue(node) { /* - We set the final value just before calcualting the new value, since the new calculated + We set the final value just before calculating the new value, since the new calculated value is going to be discarded if the position is closed after it is calculated, but during the same candle. */ @@ -158,7 +158,7 @@ exports.newSuperalgosBotModulesTradingPosition = function (processIndex) { function updateStopLossTakeProfitBeginEnd(node) { /* Both the Stop Loss and the Take Profit have their own Begin and End. - Ther reason for this is because they represent targets to be checked + The reason for this is because they represent targets to be checked at the next candle, so it does not apply that they share the begin and end of the position itself. */ diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js index e00bf4b43..cbf957349 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSystem.js @@ -403,6 +403,19 @@ exports.newSuperalgosBotModulesTradingSystem = function (processIndex) { tradingSystem.values.push([node.id, value]) tradingSystem.formulas.set(node.id, value) + } else { + + docs = { + project: 'Superalgos', + category: 'Topic', + type: 'TS LF Trading Bot Error - Formula Value Not A Number', + placeholder: {} + } + TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, undefined, node.name, node.code, undefined, value) + + tradingSystem.addError([node.id, 'Formula needs to return a numeric value.', docs]) + return + } }