From dd0364f3ff74c79912bdae15e708b7ad0c7be4d3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 7 Mar 2019 19:31:47 +0100 Subject: [PATCH] Sell Points --- ConditionsPanel.js | 86 +++++++++++++++++++++++++++++--------------- TradingSimulation.js | 16 +++------ 2 files changed, 62 insertions(+), 40 deletions(-) diff --git a/ConditionsPanel.js b/ConditionsPanel.js index fe9087e59..6302815a0 100644 --- a/ConditionsPanel.js +++ b/ConditionsPanel.js @@ -22,10 +22,10 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { function initialize() { - thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL; - thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 1; + thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL * 2; + thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * 2; - thisObject.container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 2; + thisObject.container.frame.position.x = viewPort.visibleArea.topRight.x - UI_PANEL.WIDTH.NORMAL * 3; thisObject.container.frame.position.y = viewPort.visibleArea.topRight.y; } @@ -74,13 +74,14 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { const frameBodyHeight = thisObject.container.frame.getBodyHeight(); const frameTitleHeight = thisObject.container.frame.height - frameBodyHeight; - const X_AXIS = thisObject.container.frame.width / 2; + const X_AXIS = thisObject.container.frame.width * 1 / 10; const Y_AXIS = frameTitleHeight + frameBodyHeight / 2; let y = 0; - let increment = 0.06; + let increment = 0.03; let opacity; let label; + let indent = 5; browserCanvasContext.beginPath(); @@ -99,36 +100,63 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { y = y + increment; opacity = '0.50'; - label = 'Entry Point'; - printLabel(label, X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); + label = 'Entry Points'; + printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); for (let k = 0; k < strategy.entryPoint.situations.length; k++) { let situation = strategy.entryPoint.situations[k]; + processSituation(situation); + } + + y = y + increment; + opacity = '0.50'; + label = 'Exit Points'; + printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); + + for (let k = 0; k < strategy.exitPoint.situations.length; k++) { + + let situation = strategy.exitPoint.situations[k]; + processSituation(situation); + } + + y = y + increment; + opacity = '0.50'; + label = 'Sell Points'; + printLabel(label, X_AXIS + indent * 1, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); + + for (let k = 0; k < strategy.sellPoint.situations.length; k++) { + + let situation = strategy.sellPoint.situations[k]; + processSituation(situation); + } + } + + function processSituation(situation) { + + y = y + increment; + opacity = '0.50'; + label = 'Situation: ' + situation.name; + printLabel(label, X_AXIS + indent * 2, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let color; y = y + increment; - opacity = '0.50'; - label = 'Situation: ' + situation.name; - printLabel(label, X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity, UI_COLOR.DARK); - - for (let m = 0; m < situation.conditions.length; m++) { - - let condition = situation.conditions[m]; - let color; - - y = y + increment; - if (currentRecord.conditionsValues[conditionIndex] === 1) { - opacity = '0.50' - color = UI_COLOR.PATINATED_TURQUOISE; - } else { - opacity = '0.50'; - color = UI_COLOR.RUSTED_RED; - } - conditionIndex++; - label = condition.name; - printLabel(label, X_AXIS, frameTitleHeight + frameBodyHeight * y, opacity, color); + if (currentRecord.conditionsValues[conditionIndex] === 1) { + opacity = '0.50' + color = UI_COLOR.PATINATED_TURQUOISE; + } else { + opacity = '0.50'; + color = UI_COLOR.RUSTED_RED; } + conditionIndex++; + label = condition.name; + printLabel(label, X_AXIS + indent * 3, frameTitleHeight + frameBodyHeight * y, opacity, color); } + } function printLabel(labelToPrint, x, y, opacity, color) { @@ -145,7 +173,7 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO; labelPoint = { - x: x - xOffset, + x: x, y: y }; @@ -166,3 +194,5 @@ function newAAMastersPlottersTradingSimulationConditionsConditionsPanel() { + + diff --git a/TradingSimulation.js b/TradingSimulation.js index c9bd8e390..8239cb2be 100644 --- a/TradingSimulation.js +++ b/TradingSimulation.js @@ -573,8 +573,7 @@ if (record.type === 'Buy@BuyOrder') { directionShort = -1; } if (record.type === 'Buy@StopLoss') { directionShort = 1; } - if (record.type === 'Sell-1') { directionShort = +1; } - if (record.type === 'Sell-2') { directionShort = +1; } + if (record.type === 'Sell') { directionShort = +1; } if (strategyPhase > 0) { if (strategyPhase % 2 !== 0) { //Depending if the phase is oddd or even goes above or below. @@ -974,20 +973,13 @@ } } - if (record.type === 'Sell-1') { + if (record.type === 'Sell') { - line1 = 'Sold on'; - line2 = 'condition 1.'; + line1 = 'Sold'; + line2 = ''; imageToDraw = smileyMonkeyEyes; } - if (record.type === 'Sell-2') { - - line1 = 'Sold on'; - line2 = 'condition 2.'; - - imageToDraw = smileyMonkeyEars; - } if (imageToDraw !== undefined) {