diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js index 62f4f6a44..5501ba4f2 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStages.js @@ -1255,7 +1255,8 @@ exports.newSuperalgosBotModulesTradingStages = function (processIndex) { function checkUserDefinedCode(stage, status, when) { let tradingSystemStage = getTradingSystemStage(stage); - if (tradingSystemStage.userDefinedCode !== undefined) { + if (tradingSystemStage !== undefined && + tradingSystemStage.userDefinedCode !== undefined) { if (status === 'Running' && when !== tradingSystemStage.userDefinedCode.config.whileAtStageWhenToRun) { return; } switch(status) {