FitFunction Implemented

This commit is contained in:
Luis Fernando Molina committed 2020-01-11 19:55:54 +01:00
1 parent 2e98b587f6
commit fbb240f6f3
4 files changed
+77 -5

No files matched your search

+25
View File
@@ -13,6 +13,7 @@
initialize: initialize,
finalize: finalize,
container: undefined,
fitFunction: undefined,
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
@@ -63,6 +64,7 @@
plotElements = undefined;
plotLines = undefined;
thisObject.fitFunction = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] ' + MODULE_NAME + ' -> finalize -> err = " + err.stack.stack); }
}
@@ -372,6 +374,7 @@
if (point.x < viewPort.visibleArea.bottomLeft.x || point.x > viewPort.visibleArea.bottomRight.x) { continue; }
point = viewPort.fitIntoVisibleArea(point);
point = thisObject.fitFunction(point);
let isCurrentRecord = false;
@@ -409,14 +412,17 @@
point1 = coordinateSystem.transformThisPoint(point1);
point1 = transformThisPoint(point1, thisObject.container);
point1 = viewPort.fitIntoVisibleArea(point1);
point1 = thisObject.fitFunction(point1);
point2 = coordinateSystem.transformThisPoint(point2);
point2 = transformThisPoint(point2, thisObject.container);
point2 = viewPort.fitIntoVisibleArea(point2);
point2 = thisObject.fitFunction(point2);
point3 = coordinateSystem.transformThisPoint(point3);
point3 = transformThisPoint(point3, thisObject.container);
point3 = viewPort.fitIntoVisibleArea(point3);
point3 = thisObject.fitFunction(point3);
let diff = point2.x - point3.x;
point2.y = point2.y - diff;
@@ -426,6 +432,8 @@
point2 = viewPort.fitIntoVisibleArea(point2);
point3 = viewPort.fitIntoVisibleArea(point3);
point2 = thisObject.fitFunction(point2);
point3 = thisObject.fitFunction(point3);
browserCanvasContext.beginPath();
@@ -479,14 +487,17 @@
point1 = coordinateSystem.transformThisPoint(point1);
point1 = transformThisPoint(point1, thisObject.container);
point1 = viewPort.fitIntoVisibleArea(point1);
point1 = thisObject.fitFunction(point1);
point2 = coordinateSystem.transformThisPoint(point2);
point2 = transformThisPoint(point2, thisObject.container);
point2 = viewPort.fitIntoVisibleArea(point2);
point2 = thisObject.fitFunction(point2);
point3 = coordinateSystem.transformThisPoint(point3);
point3 = transformThisPoint(point3, thisObject.container);
point3 = viewPort.fitIntoVisibleArea(point3);
point3 = thisObject.fitFunction(point3);
let diff = point2.x - point3.x;
point2.y = point2.y + diff;
@@ -496,6 +507,8 @@
point2 = viewPort.fitIntoVisibleArea(point2);
point3 = viewPort.fitIntoVisibleArea(point3);
point2 = thisObject.fitFunction(point2);
point3 = thisObject.fitFunction(point3);
browserCanvasContext.beginPath();
@@ -547,14 +560,17 @@
point1 = coordinateSystem.transformThisPoint(point1);
point1 = transformThisPoint(point1, thisObject.container);
point1 = viewPort.fitIntoVisibleArea(point1);
point1 = thisObject.fitFunction(point1);
point2 = coordinateSystem.transformThisPoint(point2);
point2 = transformThisPoint(point2, thisObject.container);
point2 = viewPort.fitIntoVisibleArea(point2);
point2 = thisObject.fitFunction(point2);
point3 = coordinateSystem.transformThisPoint(point3);
point3 = transformThisPoint(point3, thisObject.container);
point3 = viewPort.fitIntoVisibleArea(point3);
point3 = thisObject.fitFunction(point3);
let diff = point2.x - point3.x;
point2.y = point2.y - diff;
@@ -564,6 +580,8 @@
point2 = viewPort.fitIntoVisibleArea(point2);
point3 = viewPort.fitIntoVisibleArea(point3);
point2 = thisObject.fitFunction(point2);
point3 = thisObject.fitFunction(point3);
browserCanvasContext.beginPath();
@@ -616,14 +634,17 @@
point1 = coordinateSystem.transformThisPoint(point1);
point1 = transformThisPoint(point1, thisObject.container);
point1 = viewPort.fitIntoVisibleArea(point1);
point1 = thisObject.fitFunction(point1);
point2 = coordinateSystem.transformThisPoint(point2);
point2 = transformThisPoint(point2, thisObject.container);
point2 = viewPort.fitIntoVisibleArea(point2);
point2 = thisObject.fitFunction(point2);
point3 = coordinateSystem.transformThisPoint(point3);
point3 = transformThisPoint(point3, thisObject.container);
point3 = viewPort.fitIntoVisibleArea(point3);
point3 = thisObject.fitFunction(point3);
let diff = point2.x - point3.x;
point2.y = point2.y + diff;
@@ -633,6 +654,8 @@
point2 = viewPort.fitIntoVisibleArea(point2);
point3 = viewPort.fitIntoVisibleArea(point3);
point2 = thisObject.fitFunction(point2);
point3 = thisObject.fitFunction(point3);
browserCanvasContext.beginPath();
@@ -734,10 +757,12 @@
point1 = coordinateSystem.transformThisPoint(point1);
point1 = transformThisPoint(point1, thisObject.container);
point1 = viewPort.fitIntoVisibleArea(point1);
point1 = thisObject.fitFunction(point1);
point2 = coordinateSystem.transformThisPoint(point2);
point2 = transformThisPoint(point2, thisObject.container);
point2 = viewPort.fitIntoVisibleArea(point2);
point2 = thisObject.fitFunction(point2);
browserCanvasContext.beginPath();
+7
View File
@@ -14,6 +14,7 @@
initialize: initialize,
finalize: finalize,
container: undefined,
fitFunction: undefined,
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
@@ -87,6 +88,7 @@
strategyImages = undefined;
thisObject.fitFunction = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
@@ -533,6 +535,11 @@
recordPoint3 = viewPort.fitIntoVisibleArea(recordPoint3);
recordPoint4 = viewPort.fitIntoVisibleArea(recordPoint4);
recordPoint1 = thisObject.fitFunction(recordPoint1, undefined, 30);
recordPoint2 = thisObject.fitFunction(recordPoint2, undefined, 30);
recordPoint3 = thisObject.fitFunction(recordPoint3, undefined, 30);
recordPoint4 = thisObject.fitFunction(recordPoint4, undefined, 30);
let imageSize = 20;
let imageToDraw = strategyImages[record.number];
+9
View File
@@ -14,6 +14,7 @@
initialize: initialize,
finalize: finalize,
container: undefined,
fitFunction: undefined,
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
@@ -85,6 +86,7 @@
marketFile = undefined;
fileCursor = undefined;
thisObject.fitFunction = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
@@ -512,6 +514,10 @@
recordPoint2 = viewPort.fitIntoVisibleArea(recordPoint2);
recordPoint3 = viewPort.fitIntoVisibleArea(recordPoint3);
recordPoint1 = thisObject.fitFunction(recordPoint1);
recordPoint2 = thisObject.fitFunction(recordPoint2);
recordPoint3 = thisObject.fitFunction(recordPoint3);
let line1 = '';
let line2 = '';
@@ -576,6 +582,9 @@
point.y = recordPoint3.y - 100
}
point = viewPort.fitIntoVisibleArea(point);
point = thisObject.fitFunction(point, undefined, 50);
if (
recordPoint3.x < viewPort.visibleArea.topLeft.x + 250
||
+36 -5
View File
@@ -13,6 +13,7 @@
initialize: initialize,
finalize: finalize,
container: undefined,
fitFunction: undefined,
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
@@ -91,6 +92,7 @@
marketFile = undefined;
fileCursor = undefined;
thisObject.fitFunction = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
@@ -668,7 +670,8 @@
y: recordPoint4.y + imageOffset.y
}
imagePosition = thisObject.fitFunction(imagePosition)
imagePosition = viewPort.fitIntoVisibleArea(imagePosition)
imagePosition = thisObject.fitFunction(imagePosition, undefined, 0, 0, imageSize)
if (imageRecord.canDrawIcon === true) {
browserCanvasContext.drawImage(imageRecord, imagePosition.x, imagePosition.y, imageSize, imageSize);
@@ -739,10 +742,24 @@
browserCanvasContext.lineWidth = 1
browserCanvasContext.stroke()
imagePosition = {
x: recordPoint6.x - imageSize,
y: recordPoint6.y - imageSize * 1.25 + yOffset
}
imagePosition = viewPort.fitIntoVisibleArea(imagePosition)
imagePosition = thisObject.fitFunction(imagePosition, undefined, 0, 0, imageSize)
let labelPosition = {
x: recordPoint6.x - imageSize / 2 - 3,
y: recordPoint6.y - imageSize * 1.5 + yOffset * 2
}
labelPosition = viewPort.fitIntoVisibleArea(labelPosition)
labelPosition = thisObject.fitFunction(labelPosition, undefined, 30)
if (imageStopLossPhase.canDrawIcon === true && stopLossPhase > -1) {
browserCanvasContext.drawImage(imageStopLossPhase, recordPoint6.x - imageSize, recordPoint6.y - imageSize * 1.25 + yOffset, imageSize, imageSize);
printLabel(stopLossPhase, recordPoint6.x - imageSize / 2 - 3, recordPoint6.y - imageSize * 1.5 + yOffset * 2, '1', 9);
browserCanvasContext.drawImage(imageStopLossPhase, imagePosition.x, imagePosition.y, imageSize, imageSize);
printLabel(stopLossPhase, labelPosition.x, labelPosition.y, '1', 9);
}
/* Next we are drawing the Take Profit */
@@ -767,9 +784,23 @@
browserCanvasContext.lineWidth = 1
browserCanvasContext.stroke()
imagePosition = {
x: recordPoint10.x - imageSize * 2 / 3,
y: recordPoint10.y + imageSize / 4 - yOffset
}
imagePosition = viewPort.fitIntoVisibleArea(imagePosition)
imagePosition = thisObject.fitFunction(imagePosition, undefined, 0, 0, imageSize)
labelPosition = {
x: recordPoint10.x - imageSize * 1 / 3,
y: recordPoint10.y + imageSize * 1.9 - yOffset * 2
}
labelPosition = viewPort.fitIntoVisibleArea(labelPosition)
labelPosition = thisObject.fitFunction(labelPosition, undefined, 30)
if (imageTakeProfitPhase.canDrawIcon === true && takeProfitPhase > -1) {
browserCanvasContext.drawImage(imageTakeProfitPhase, recordPoint10.x - imageSize * 2 / 3, recordPoint10.y + imageSize / 4 - yOffset, imageSize, imageSize);
printLabel(takeProfitPhase, recordPoint10.x - imageSize * 1 / 3, recordPoint10.y + imageSize * 1.9 - yOffset * 2, '1', 9);
browserCanvasContext.drawImage(imageTakeProfitPhase, imagePosition.x, imagePosition.y, imageSize, imageSize);
printLabel(takeProfitPhase, labelPosition.x, labelPosition.y, '1', 9);
}
}