From bd905cb4ac5f22d8c8eda8026a259aeaa4940401 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 8 Mar 2019 14:29:28 +0100 Subject: [PATCH] Conditional display of conditions --- ConditionsPanel.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/ConditionsPanel.js b/ConditionsPanel.js index 39389a392..b09e6994c 100644 --- a/ConditionsPanel.js +++ b/ConditionsPanel.js @@ -82,22 +82,27 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { let opacity; let label; let indent = 5; + let showLabel; browserCanvasContext.beginPath(); let simulationLogic = currentRecord.conditionsNames; - let conditionIndex = 0; + let conditionIndex = 0; for (let j = 0; j < simulationLogic.strategies.length; j++) { let strategy = simulationLogic.strategies[j]; - y = y + increment; + showLabel = true; + + if (currentRecord.strategyNumber > 0 && currentRecord.strategyNumber - 1 !== j) { showLabel = false; } + + if (showLabel) { y = y + increment; } opacity = '1.00'; label = 'Strategy: ' + strategy.name; printLabel(label, X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); - y = y + increment; + if (showLabel) { y = y + increment; } opacity = '0.50'; label = 'Entry Points'; printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); @@ -108,7 +113,7 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { processSituation(situation); } - y = y + increment; + if (showLabel) { y = y + increment; } opacity = '0.50'; label = 'Exit Points'; printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); @@ -119,7 +124,9 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { processSituation(situation); } - y = y + increment; + if (currentRecord.strategyNumber - 1 !== j) { showLabel = false; } + + if (showLabel) { y = y + increment; } opacity = '0.50'; label = 'Sell Points'; printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); @@ -130,7 +137,7 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { processSituation(situation); } - y = y + increment; + if (showLabel) { y = y + increment; } opacity = '0.50'; label = 'Stop Loss Management'; printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); @@ -139,7 +146,7 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { let phase = strategy.stopLoss.phases[p]; - y = y + increment; + if (showLabel) { y = y + increment; } opacity = '0.50'; label = 'Phase: ' + phase.name; printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); @@ -151,7 +158,7 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { } } - y = y + increment; + if (showLabel) { y = y + increment; } opacity = '0.50'; label = 'Buy Order Management'; printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); @@ -160,7 +167,7 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { let phase = strategy.buyOrder.phases[p]; - y = y + increment; + if (showLabel) { y = y + increment; } opacity = '0.50'; label = 'Phase: ' + phase.name; printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); @@ -175,7 +182,7 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { function processSituation(situation) { - y = y + increment; + if (showLabel) { y = y + increment; } opacity = '0.50'; label = 'Situation: ' + situation.name; printLabel(label, X_AXIS + indent * 2, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); @@ -185,7 +192,7 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { let condition = situation.conditions[m]; let color; - y = y + increment; + if (showLabel) { y = y + increment; } if (currentRecord.conditionsValues[conditionIndex] === 1) { opacity = '0.50' color = UI_COLOR.PATINATED_TURQUOISE; @@ -197,11 +204,12 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { label = condition.name; printLabel(label, X_AXIS + indent * 3, frameTitleHeight + frameBodyHeight * y, opacity, color); } - } function printLabel(labelToPrint, x, y, opacity, color) { + if (showLabel === false) { return; } + let labelPoint; let fontSize = 10; @@ -238,3 +246,4 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { +