diff --git a/SimulationExecution.js b/SimulationExecution.js index d6d2c82e4..80def9f64 100644 --- a/SimulationExecution.js +++ b/SimulationExecution.js @@ -17,6 +17,7 @@ getContainer: getContainer, setTimeFrame: setTimeFrame, setDatetime: setDatetime, + setCoordinateSystem: setCoordinateSystem, recalculateScale: recalculateScale, draw: draw }; @@ -27,7 +28,7 @@ container.initialize(); thisObject.container = container; - let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -65,22 +66,24 @@ plotLines = undefined; thisObject.fitFunction = undefined + + coordinateSystem = undefined } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] ' + MODULE_NAME + ' -> finalize -> err = " + err.stack.stack); } } } - function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) { + function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) { try { datetime = pDatetime; timeFrame = pTimeFrame; + coordinateSystem = pCoordinateSystem fileSequence = pStorage.fileSequences[0]; recalculate(); - recalculateScale(); filesUpdatedEventSubscriptionId = fileSequence.eventHandler.listenToEvent("Files Updated", onFilesUpdated); // Only the first sequence is supported right now. offsetChangedEventSubscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent("Position Changed", onViewportPositionChanged); @@ -89,7 +92,6 @@ dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () { recalculate(); - recalculateScale(); }) callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); @@ -123,8 +125,12 @@ recalculate(); } - function setDatetime(newDatetime) { - datetime = newDatetime; + function setDatetime(pDatetime) { + datetime = pDatetime; + } + + function setCoordinateSystem(pCoordinateSystem) { + coordinateSystem = pCoordinateSystem } function onViewportPositionChanged() { diff --git a/Strategies.js b/Strategies.js index bda368538..4f8aa50eb 100644 --- a/Strategies.js +++ b/Strategies.js @@ -18,6 +18,7 @@ getContainer: getContainer, setTimeFrame: setTimeFrame, setDatetime: setDatetime, + setCoordinateSystem: setCoordinateSystem, draw: draw, recalculateScale: recalculateScale, @@ -36,7 +37,7 @@ container.initialize(); thisObject.container = container; - let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -89,13 +90,15 @@ strategyImages = undefined; thisObject.fitFunction = undefined + + coordinateSystem = undefined } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); } } } - function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) { + function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) { try { @@ -108,13 +111,12 @@ datetime = pDatetime; timeFrame = pTimeFrame; + coordinateSystem = pCoordinateSystem /* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */ marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster. - recalculateScale(); - /* Now we set the right files according to current Period. */ marketFile = marketFiles.getFile(pTimeFrame); @@ -135,7 +137,6 @@ /* Ready for when dimmension changes. */ dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () { - recalculateScale() recalculate(); }) @@ -234,11 +235,11 @@ } function setDatetime(pDatetime) { - - if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); } - datetime = pDatetime; + } + function setCoordinateSystem(pCoordinateSystem) { + coordinateSystem = pCoordinateSystem } function onDailyFileLoaded(event) { diff --git a/Trades.js b/Trades.js index b7ac90273..daecc4c02 100644 --- a/Trades.js +++ b/Trades.js @@ -18,6 +18,7 @@ getContainer: getContainer, setTimeFrame: setTimeFrame, setDatetime: setDatetime, + setCoordinateSystem: setCoordinateSystem, draw: draw, recalculateScale: recalculateScale, @@ -36,7 +37,7 @@ container.initialize(); thisObject.container = container; - let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -87,13 +88,15 @@ fileCursor = undefined; thisObject.fitFunction = undefined + + coordinateSystem = undefined } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); } } } - function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) { + function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) { try { @@ -106,13 +109,12 @@ datetime = pDatetime; timeFrame = pTimeFrame; + coordinateSystem = pCoordinateSystem /* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */ marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster. - recalculateScale(); - /* Now we set the right files according to current Period. */ marketFile = marketFiles.getFile(pTimeFrame); @@ -133,7 +135,6 @@ /* Ready for when dimmension changes. */ dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () { - recalculateScale() recalculate(); }) @@ -227,11 +228,11 @@ } function setDatetime(pDatetime) { - - if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); } - datetime = pDatetime; + } + function setCoordinateSystem(pCoordinateSystem) { + coordinateSystem = pCoordinateSystem } function onDailyFileLoaded(event) { diff --git a/TradingSimulation.js b/TradingSimulation.js index 8353cf7aa..98a85bd6b 100644 --- a/TradingSimulation.js +++ b/TradingSimulation.js @@ -17,6 +17,7 @@ getContainer: getContainer, setTimeFrame: setTimeFrame, setDatetime: setDatetime, + setCoordinateSystem: setCoordinateSystem, draw: draw, recalculateScale: recalculateScale, @@ -35,7 +36,7 @@ container.initialize(); thisObject.container = container; - let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -93,13 +94,15 @@ fileCursor = undefined; thisObject.fitFunction = undefined + + coordinateSystem = undefined } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); } } } - function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) { + function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) { try { @@ -110,13 +113,12 @@ datetime = pDatetime; timeFrame = pTimeFrame; + coordinateSystem = pCoordinateSystem /* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */ marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster. - recalculateScale(); - /* Now we set the right files according to current Period. */ marketFile = marketFiles.getFile(pTimeFrame); @@ -137,7 +139,6 @@ /* Ready for when dimmension changes. */ dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () { - recalculateScale() recalculate(); }) @@ -221,9 +222,11 @@ } function setDatetime(pDatetime) { - datetime = pDatetime; + } + function setCoordinateSystem(pCoordinateSystem) { + coordinateSystem = pCoordinateSystem } function onDailyFileLoaded(event) {