History implemented
This commit is contained in:
1 parent
e393232c7a
commit
61017082a4
3 files changed
+46
-489
No files matched your search
Binary file not shown.
+1
-1
@@ -737,7 +737,7 @@
|
||||
|
||||
function onLayerStatusChanged(eventData) {
|
||||
|
||||
if (eventData.layer === 'Olivia Volumes') {
|
||||
if (eventData.layer === 'Mariam Trades Details') {
|
||||
layerStatus = eventData.status;
|
||||
}
|
||||
|
||||
|
||||
+45
-488
@@ -1,4 +1,4 @@
|
||||
function newAAMastersAAOliviaCandles() {
|
||||
function newAAMastersAAMariamTradingHistory() {
|
||||
|
||||
let thisObject = {
|
||||
|
||||
@@ -31,91 +31,26 @@
|
||||
let timePeriod; // This will hold the current Time Period the user is at.
|
||||
let datetime; // This will hold the current Datetime the user is at.
|
||||
|
||||
let marketFile; // This is the current Market File being plotted.
|
||||
let fileCursor; // This is the current File Cursor being used to retrieve Daily Files.
|
||||
|
||||
let fileCache; // This object will provide the different Market Files at different Time Periods.
|
||||
let fileCursorCache; // This object will provide the different File Cursors at different Time Periods.
|
||||
|
||||
/* these are module specific variables: */
|
||||
|
||||
let candles = []; // Here we keep the candles to be ploted every time the Draw() function is called by the AAWebPlatform.
|
||||
let file; // Here we keep the history records to be ploted every time the Draw() function is called by the AAWebPlatform.
|
||||
let history = []; // This is where the history records are stored before plotting.
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(pExchange, pMarket, pDatetime, pTimePeriod, pLayerStatus, callBackFunction) {
|
||||
|
||||
let cursorCacheInProgress = false;
|
||||
let finaleStepsInProgress = false;
|
||||
|
||||
datetime = pDatetime;
|
||||
timePeriod = pTimePeriod;
|
||||
|
||||
fileCache = newFileCache();
|
||||
fileCache.initialize("AAMasters", "AAOlivia", "Market Candles", "Market Candlesticks", pExchange, pMarket, onFileReady);
|
||||
let File = newFile();
|
||||
File.initialize("AAMasters", "AAMariam", "Trading History", "Trading History", pExchange, pMarket, onFileReady)
|
||||
|
||||
function onFileReady() {
|
||||
|
||||
let newMarketFile = fileCache.getFile(ONE_DAY_IN_MILISECONDS);
|
||||
|
||||
if (newMarketFile !== undefined) {
|
||||
|
||||
marketFile = newMarketFile;
|
||||
|
||||
initializeFileCursorCache();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function initializeFileCursorCache() {
|
||||
|
||||
if (cursorCacheInProgress === false) {
|
||||
|
||||
cursorCacheInProgress = true;
|
||||
|
||||
fileCursorCache = newFileCursorCache();
|
||||
fileCursorCache.initialize("AAMasters", "AAOlivia", "Daily Candles", "Daily Candlesticks", pExchange, pMarket, pDatetime, pTimePeriod, onFileCursorReady);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function onFileCursorReady() {
|
||||
|
||||
recalculate();
|
||||
|
||||
let newFileCursor = fileCursorCache.getFileCursor(pTimePeriod);
|
||||
|
||||
if (newFileCursor !== undefined) { // if the file ready is the one we need then it and we dont have it yet, then we will continue here.
|
||||
|
||||
let stringDate = datetime.getUTCFullYear() + '-' + pad(datetime.getUTCMonth() + 1, 2) + '-' + pad(datetime.getUTCDate(), 2);
|
||||
|
||||
let dailyFile = newFileCursor.files.get(stringDate);
|
||||
|
||||
if (dailyFile !== undefined) {
|
||||
|
||||
if (finaleStepsInProgress === false) {
|
||||
|
||||
finaleStepsInProgress = true;
|
||||
|
||||
fileCursor = newFileCursor;
|
||||
|
||||
recalculateScale(); // With any of the market files we can calculate the scale.
|
||||
|
||||
layerStatus = pLayerStatus;
|
||||
|
||||
recalculate();
|
||||
|
||||
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
|
||||
canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
|
||||
|
||||
callBackFunction();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
file = File.getFile();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
@@ -143,141 +78,18 @@
|
||||
|
||||
timePeriod = pTimePeriod;
|
||||
|
||||
if (timePeriod >= _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
let newMarketFile = fileCache.getFile(pTimePeriod);
|
||||
|
||||
if (newMarketFile !== undefined) {
|
||||
|
||||
marketFile = newMarketFile;
|
||||
|
||||
recalculate();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
fileCursorCache.setTimePeriod(pTimePeriod);
|
||||
|
||||
fileCursorCache.setDatetime(datetime);
|
||||
|
||||
let newFileCursor = fileCursorCache.getFileCursor(pTimePeriod);
|
||||
|
||||
if (newFileCursor !== undefined) {
|
||||
|
||||
fileCursor = newFileCursor;
|
||||
|
||||
recalculate();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (timePeriod === _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
fileCursorCache.setTimePeriod(pTimePeriod);
|
||||
|
||||
fileCursorCache.setDatetime(datetime);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function setDatetime(newDatetime) {
|
||||
|
||||
/* If there is a change in the day, then we take some actions, otherwise, we dont. */
|
||||
|
||||
let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
||||
let newDate = Math.trunc(newDatetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
||||
|
||||
datetime = newDatetime;
|
||||
|
||||
if (currentDate !== newDate) {
|
||||
|
||||
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
fileCursorCache.setDatetime(newDatetime);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function positionAtDatetime(newDatetime) {
|
||||
|
||||
value = newDatetime.valueOf();
|
||||
|
||||
/* Now we calculate which candle has this new time, because it will give us the y coordinate. */
|
||||
|
||||
for (let i = 0; i < candles.length; i++) {
|
||||
|
||||
if (value >= candles[i].begin && value <= candles[i].end) {
|
||||
|
||||
let targetPoint = {
|
||||
x: value,
|
||||
y: candles[i].open
|
||||
};
|
||||
|
||||
targetPoint = plotArea.inverseTransform(targetPoint, thisObject.container.frame.height);
|
||||
targetPoint = transformThisPoint(targetPoint, thisObject.container);
|
||||
|
||||
let targetMax = {
|
||||
x: value,
|
||||
y: candles[i].max
|
||||
};
|
||||
|
||||
targetMax = plotArea.inverseTransform(targetMax, thisObject.container.frame.height);
|
||||
targetMax = transformThisPoint(targetMax, thisObject.container);
|
||||
|
||||
let targetMin = {
|
||||
x: value,
|
||||
y: candles[i].min
|
||||
};
|
||||
|
||||
targetMin = plotArea.inverseTransform(targetMin, thisObject.container.frame.height);
|
||||
targetMin = transformThisPoint(targetMin, thisObject.container);
|
||||
|
||||
let center = {
|
||||
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.bottomLeft.x) / 2,
|
||||
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2
|
||||
};
|
||||
|
||||
if (targetMax.y < viewPort.visibleArea.topLeft.y || targetMin.y > viewPort.visibleArea.bottomRight.y) {
|
||||
|
||||
let displaceVector = {
|
||||
x: 0,
|
||||
y: center.y - targetPoint.y
|
||||
};
|
||||
|
||||
viewPort.displaceTarget(displaceVector);
|
||||
|
||||
}
|
||||
|
||||
let displaceVector = {
|
||||
x: center.x - targetPoint.x,
|
||||
y: 0
|
||||
};
|
||||
|
||||
viewPort.displace(displaceVector);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
|
||||
if (layerStatus !== 'on') { return; }
|
||||
|
||||
this.container.frame.draw();
|
||||
|
||||
if (timePeriod < _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
if (Math.random() * 1000 > 995) {
|
||||
|
||||
recalculate();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
plotChart();
|
||||
|
||||
}
|
||||
@@ -286,167 +98,26 @@
|
||||
|
||||
if (layerStatus === 'off') { return; }
|
||||
|
||||
if (timePeriod >= _1_HOUR_IN_MILISECONDS) {
|
||||
for (let i = 0; i < file.length; i++) {
|
||||
|
||||
recalculateUsingMarketFiles();
|
||||
let newHistoryRecord = {
|
||||
|
||||
} else {
|
||||
|
||||
recalculateUsingDailyFiles();
|
||||
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.raiseEvent("Candles Changed", candles);
|
||||
}
|
||||
|
||||
function recalculateUsingDailyFiles() {
|
||||
|
||||
if (fileCursor.files.size === 0) { return;} // We need to wait until there are files in the cursor
|
||||
|
||||
let daysOnSides = getSideDays(timePeriod);
|
||||
|
||||
let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, plotArea);
|
||||
let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, plotArea);
|
||||
|
||||
let dateDiff = rightDate.valueOf() - leftDate.valueOf();
|
||||
|
||||
let farLeftDate = new Date(leftDate.valueOf() - dateDiff * 1.5);
|
||||
let farRightDate = new Date(rightDate.valueOf() + dateDiff * 1.5);
|
||||
|
||||
let currentDate = new Date(farLeftDate.valueOf());
|
||||
|
||||
candles = [];
|
||||
|
||||
while (currentDate.valueOf() <= farRightDate.valueOf() + ONE_DAY_IN_MILISECONDS) {
|
||||
|
||||
let stringDate = currentDate.getFullYear() + '-' + pad(currentDate.getMonth() + 1, 2) + '-' + pad(currentDate.getDate(), 2);
|
||||
|
||||
let dailyFile = fileCursor.files.get(stringDate);
|
||||
|
||||
if (dailyFile !== undefined) {
|
||||
|
||||
for (let i = 0; i < dailyFile.length; i++) {
|
||||
|
||||
let candle = {
|
||||
open: undefined,
|
||||
close: undefined,
|
||||
min: 10000000000000,
|
||||
max: 0,
|
||||
begin: undefined,
|
||||
end: undefined,
|
||||
direction: undefined
|
||||
};
|
||||
|
||||
candle.min = dailyFile[i][0];
|
||||
candle.max = dailyFile[i][1];
|
||||
|
||||
candle.open = dailyFile[i][2];
|
||||
candle.close = dailyFile[i][3];
|
||||
|
||||
candle.begin = dailyFile[i][4];
|
||||
candle.end = dailyFile[i][5];
|
||||
|
||||
if (candle.open > candle.close) { candle.direction = 'down'; }
|
||||
if (candle.open < candle.close) { candle.direction = 'up'; }
|
||||
if (candle.open === candle.close) { candle.direction = 'side'; }
|
||||
|
||||
if (candle.begin >= farLeftDate.valueOf() && candle.end <= farRightDate.valueOf()) {
|
||||
|
||||
candles.push(candle);
|
||||
|
||||
if (datetime.valueOf() >= candle.begin && datetime.valueOf() <= candle.end) {
|
||||
|
||||
thisObject.currentCandle = candle;
|
||||
thisObject.container.eventHandler.raiseEvent("Current Candle Changed", thisObject.currentCandle);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentDate = new Date(currentDate.valueOf() + ONE_DAY_IN_MILISECONDS);
|
||||
}
|
||||
|
||||
/* Lests check if all the visible screen is going to be covered by candles. */
|
||||
|
||||
let lowerEnd = leftDate.valueOf();
|
||||
let upperEnd = rightDate.valueOf();
|
||||
|
||||
if (candles.length > 0) {
|
||||
|
||||
if (candles[0].begin > lowerEnd || candles[candles.length - 1].end < upperEnd) {
|
||||
|
||||
setTimeout(recalculate, 2000);
|
||||
|
||||
//console.log("File missing while calculating candles, scheduling a recalculation in 2 seconds.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//console.log("Olivia > recalculateUsingDailyFiles > total candles generated : " + candles.length);
|
||||
|
||||
}
|
||||
|
||||
function recalculateUsingMarketFiles() {
|
||||
|
||||
if (marketFile === undefined) { return; } // Initialization not complete yet.
|
||||
|
||||
let daysOnSides = getSideDays(timePeriod);
|
||||
|
||||
let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, plotArea);
|
||||
let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, plotArea);
|
||||
|
||||
let dateDiff = rightDate.valueOf() - leftDate.valueOf();
|
||||
|
||||
leftDate = new Date(leftDate.valueOf() - dateDiff * 1.5);
|
||||
rightDate = new Date(rightDate.valueOf() + dateDiff * 1.5);
|
||||
|
||||
candles = [];
|
||||
|
||||
for (let i = 0; i < marketFile.length; i++) {
|
||||
|
||||
let candle = {
|
||||
open: undefined,
|
||||
close: undefined,
|
||||
min: 10000000000000,
|
||||
max: 0,
|
||||
begin: undefined,
|
||||
end: undefined,
|
||||
direction: undefined
|
||||
date: Math.trunc(file[i][0] / 60000) * 60000 + 30000,
|
||||
rate: file[i][1],
|
||||
newPositions: file[i][2],
|
||||
newTrades: file[i][3],
|
||||
movedPositions: file[i][4]
|
||||
};
|
||||
|
||||
candle.min = marketFile[i][0];
|
||||
candle.max = marketFile[i][1];
|
||||
|
||||
candle.open = marketFile[i][2];
|
||||
candle.close = marketFile[i][3];
|
||||
|
||||
candle.begin = marketFile[i][4];
|
||||
candle.end = marketFile[i][5];
|
||||
|
||||
if (candle.open > candle.close) { candle.direction = 'down'; }
|
||||
if (candle.open < candle.close) { candle.direction = 'up'; }
|
||||
if (candle.open === candle.close) { candle.direction = 'side'; }
|
||||
|
||||
if (candle.begin >= leftDate.valueOf() && candle.end <= rightDate.valueOf()) {
|
||||
|
||||
candles.push(candle);
|
||||
|
||||
if (datetime.valueOf() >= candle.begin && datetime.valueOf() <= candle.end) {
|
||||
|
||||
thisObject.currentCandle = candle;
|
||||
thisObject.container.eventHandler.raiseEvent("Current Candle Changed", thisObject.currentCandle);
|
||||
|
||||
}
|
||||
}
|
||||
history.push(newHistoryRecord);
|
||||
}
|
||||
|
||||
//console.log("Olivia > recalculateUsingMarketFiles > total candles generated : " + candles.length);
|
||||
thisObject.container.eventHandler.raiseEvent("History Changed", history);
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
if (marketFile === undefined) { return; } // We need the market file to be loaded to make the calculation.
|
||||
if (file === undefined) { return; } // We need the market file to be loaded to make the calculation.
|
||||
|
||||
if (plotArea.maxValue > 0) { return; } // Already calculated.
|
||||
|
||||
@@ -472,7 +143,7 @@
|
||||
|
||||
let maxValue = 0;
|
||||
|
||||
for (let i = 0; i < marketFile.length; i++) {
|
||||
for (let i = 0; i < file.length; i++) {
|
||||
|
||||
let currentMax = marketFile[i][1]; // 1 = rates.
|
||||
|
||||
@@ -489,176 +160,66 @@
|
||||
|
||||
function plotChart() {
|
||||
|
||||
if (candles.length > 0) {
|
||||
for (let i = 0; i < history.length; i++) {
|
||||
|
||||
/* Now we calculate and plot the candles */
|
||||
record = history[i];
|
||||
|
||||
for (let i = 0; i < candles.length; i++) {
|
||||
|
||||
candle = candles[i];
|
||||
|
||||
let candlePoint1 = {
|
||||
x: candle.begin + timePeriod / 7 * 1.5,
|
||||
y: candle.open
|
||||
let point = {
|
||||
x: record.begin + timePeriod / 7 * 1.5,
|
||||
y: record.open
|
||||
};
|
||||
|
||||
let candlePoint2 = {
|
||||
x: candle.begin + timePeriod / 7 * 5.5,
|
||||
y: candle.open
|
||||
};
|
||||
point = plotArea.inverseTransform(point, thisObject.container.frame.height);
|
||||
|
||||
let candlePoint3 = {
|
||||
x: candle.begin + timePeriod / 7 * 5.5,
|
||||
y: candle.close
|
||||
};
|
||||
point = transformThisPoint(point, thisObject.container);
|
||||
|
||||
let candlePoint4 = {
|
||||
x: candle.begin + timePeriod / 7 * 1.5,
|
||||
y: candle.close
|
||||
};
|
||||
|
||||
candlePoint1 = plotArea.inverseTransform(candlePoint1, thisObject.container.frame.height);
|
||||
candlePoint2 = plotArea.inverseTransform(candlePoint2, thisObject.container.frame.height);
|
||||
candlePoint3 = plotArea.inverseTransform(candlePoint3, thisObject.container.frame.height);
|
||||
candlePoint4 = plotArea.inverseTransform(candlePoint4, thisObject.container.frame.height);
|
||||
|
||||
candlePoint1 = transformThisPoint(candlePoint1, thisObject.container);
|
||||
candlePoint2 = transformThisPoint(candlePoint2, thisObject.container);
|
||||
candlePoint3 = transformThisPoint(candlePoint3, thisObject.container);
|
||||
candlePoint4 = transformThisPoint(candlePoint4, thisObject.container);
|
||||
|
||||
if (candlePoint2.x < viewPort.visibleArea.bottomLeft.x || candlePoint1.x > viewPort.visibleArea.bottomRight.x) {
|
||||
if (point.x < viewPort.visibleArea.bottomLeft.x || point.x > viewPort.visibleArea.bottomRight.x) {
|
||||
continue;
|
||||
}
|
||||
|
||||
candlePoint1 = viewPort.fitIntoVisibleArea(candlePoint1);
|
||||
candlePoint2 = viewPort.fitIntoVisibleArea(candlePoint2);
|
||||
candlePoint3 = viewPort.fitIntoVisibleArea(candlePoint3);
|
||||
candlePoint4 = viewPort.fitIntoVisibleArea(candlePoint4);
|
||||
|
||||
let stickPoint1 = {
|
||||
x: candle.begin + timePeriod / 7 * 3.2,
|
||||
y: candle.max
|
||||
};
|
||||
|
||||
let stickPoint2 = {
|
||||
x: candle.begin + timePeriod / 7 * 3.8,
|
||||
y: candle.max
|
||||
};
|
||||
|
||||
let stickPoint3 = {
|
||||
x: candle.begin + timePeriod / 7 * 3.8,
|
||||
y: candle.min
|
||||
};
|
||||
|
||||
let stickPoint4 = {
|
||||
x: candle.begin + timePeriod / 7 * 3.2,
|
||||
y: candle.min
|
||||
};
|
||||
|
||||
stickPoint1 = plotArea.inverseTransform(stickPoint1, thisObject.container.frame.height);
|
||||
stickPoint2 = plotArea.inverseTransform(stickPoint2, thisObject.container.frame.height);
|
||||
stickPoint3 = plotArea.inverseTransform(stickPoint3, thisObject.container.frame.height);
|
||||
stickPoint4 = plotArea.inverseTransform(stickPoint4, thisObject.container.frame.height);
|
||||
|
||||
stickPoint1 = transformThisPoint(stickPoint1, thisObject.container);
|
||||
stickPoint2 = transformThisPoint(stickPoint2, thisObject.container);
|
||||
stickPoint3 = transformThisPoint(stickPoint3, thisObject.container);
|
||||
stickPoint4 = transformThisPoint(stickPoint4, thisObject.container);
|
||||
|
||||
stickPoint1 = viewPort.fitIntoVisibleArea(stickPoint1);
|
||||
stickPoint2 = viewPort.fitIntoVisibleArea(stickPoint2);
|
||||
stickPoint3 = viewPort.fitIntoVisibleArea(stickPoint3);
|
||||
stickPoint4 = viewPort.fitIntoVisibleArea(stickPoint4);
|
||||
point = viewPort.fitIntoVisibleArea(point);
|
||||
|
||||
browserCanvasContext.beginPath();
|
||||
|
||||
browserCanvasContext.moveTo(stickPoint1.x, stickPoint1.y);
|
||||
browserCanvasContext.lineTo(stickPoint2.x, stickPoint2.y);
|
||||
browserCanvasContext.lineTo(stickPoint3.x, stickPoint3.y);
|
||||
browserCanvasContext.lineTo(stickPoint4.x, stickPoint4.y);
|
||||
browserCanvasContext.moveTo(point.x, point.y);
|
||||
|
||||
browserCanvasContext.closePath();
|
||||
browserCanvasContext.fillStyle = 'rgba(54, 54, 54, 1)';
|
||||
browserCanvasContext.fill();
|
||||
|
||||
if (record.direction === 'up') { browserCanvasContext.strokeStyle = 'rgba(27, 105, 7, 1)'; }
|
||||
if (record.direction === 'down') { browserCanvasContext.strokeStyle = 'rgba(130, 9, 9, 1)'; }
|
||||
if (record.direction === 'side') { browserCanvasContext.strokeStyle = 'rgba(27, 7, 105, 1)'; }
|
||||
|
||||
if (datetime !== undefined) {
|
||||
|
||||
let dateValue = datetime.valueOf();
|
||||
|
||||
if (dateValue >= candle.begin && dateValue <= candle.end) {
|
||||
if (dateValue >= record.begin && dateValue <= record.end) {
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(255, 233, 31, 1)'; // Current candle accroding to time
|
||||
/* highlight the current record */
|
||||
|
||||
} else {
|
||||
browserCanvasContext.strokeStyle = 'rgba(212, 206, 201, 1)';
|
||||
}
|
||||
|
||||
} else {
|
||||
browserCanvasContext.strokeStyle = 'rgba(212, 206, 201, 1)';
|
||||
}
|
||||
|
||||
browserCanvasContext.lineWidth = 1;
|
||||
browserCanvasContext.stroke();
|
||||
|
||||
browserCanvasContext.beginPath();
|
||||
|
||||
browserCanvasContext.moveTo(candlePoint1.x, candlePoint1.y);
|
||||
browserCanvasContext.lineTo(candlePoint2.x, candlePoint2.y);
|
||||
browserCanvasContext.lineTo(candlePoint3.x, candlePoint3.y);
|
||||
browserCanvasContext.lineTo(candlePoint4.x, candlePoint4.y);
|
||||
|
||||
browserCanvasContext.closePath();
|
||||
|
||||
if (candle.direction === 'up') { browserCanvasContext.strokeStyle = 'rgba(27, 105, 7, 1)'; }
|
||||
if (candle.direction === 'down') { browserCanvasContext.strokeStyle = 'rgba(130, 9, 9, 1)'; }
|
||||
if (candle.direction === 'side') { browserCanvasContext.strokeStyle = 'rgba(27, 7, 105, 1)'; }
|
||||
|
||||
if (datetime !== undefined) {
|
||||
|
||||
let dateValue = datetime.valueOf();
|
||||
|
||||
if (dateValue >= candle.begin && dateValue <= candle.end) {
|
||||
|
||||
/* highlight the current candle */
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(255, 233, 31, 1)'; // Current candle accroding to time
|
||||
|
||||
let currentCandle = {
|
||||
bodyWidth: candlePoint2.x - candlePoint1.x,
|
||||
bodyHeight: candlePoint3.y - candlePoint2.y,
|
||||
stickHeight: stickPoint4.y - stickPoint2.y,
|
||||
stickWidth: stickPoint2.x - stickPoint1.x,
|
||||
stickStart: candlePoint2.y - stickPoint2.y,
|
||||
period: timePeriod,
|
||||
innerCandle: candle
|
||||
};
|
||||
|
||||
thisObject.container.eventHandler.raiseEvent("Current Candle Info Changed", currentCandle);
|
||||
browserCanvasContext.fillStyle = 'rgba(255, 233, 31, 1)'; // Current record accroding to time
|
||||
|
||||
} else {
|
||||
|
||||
if (candle.direction === 'up') { browserCanvasContext.fillStyle = 'rgba(64, 217, 26, 1)'; }
|
||||
if (candle.direction === 'down') { browserCanvasContext.fillStyle = 'rgba(219, 18, 18, 1)'; }
|
||||
if (candle.direction === 'side') { browserCanvasContext.fillStyle = 'rgba(64, 26, 217, 1)'; }
|
||||
if (record.direction === 'up') { browserCanvasContext.fillStyle = 'rgba(64, 217, 26, 1)'; }
|
||||
if (record.direction === 'down') { browserCanvasContext.fillStyle = 'rgba(219, 18, 18, 1)'; }
|
||||
if (record.direction === 'side') { browserCanvasContext.fillStyle = 'rgba(64, 26, 217, 1)'; }
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (candle.direction === 'up') { browserCanvasContext.fillStyle = 'rgba(64, 217, 26, 1)'; }
|
||||
if (candle.direction === 'down') { browserCanvasContext.fillStyle = 'rgba(219, 18, 18, 1)'; }
|
||||
if (candle.direction === 'side') { browserCanvasContext.fillStyle = 'rgba(64, 26, 217, 1)'; }
|
||||
if (record.direction === 'up') { browserCanvasContext.fillStyle = 'rgba(64, 217, 26, 1)'; }
|
||||
if (record.direction === 'down') { browserCanvasContext.fillStyle = 'rgba(219, 18, 18, 1)'; }
|
||||
if (record.direction === 'side') { browserCanvasContext.fillStyle = 'rgba(64, 26, 217, 1)'; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (
|
||||
candlePoint1.x < viewPort.visibleArea.topLeft.x + 50
|
||||
point.x < viewPort.visibleArea.topLeft.x + 50
|
||||
||
|
||||
candlePoint1.x > viewPort.visibleArea.bottomRight.x - 50
|
||||
point.x > viewPort.visibleArea.bottomRight.x - 50
|
||||
) {
|
||||
// we leave this candles without fill.
|
||||
// we leave this history without fill.
|
||||
} else {
|
||||
browserCanvasContext.fill();
|
||||
}
|
||||
@@ -668,12 +229,12 @@
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onLayerStatusChanged(eventData) {
|
||||
|
||||
if (eventData.layer === 'Olivia Candlesticks') {
|
||||
if (eventData.layer === 'Mariam Trades History') {
|
||||
layerStatus = eventData.status;
|
||||
}
|
||||
|
||||
@@ -681,14 +242,10 @@
|
||||
|
||||
function onZoomChanged(event) {
|
||||
|
||||
recalculate();
|
||||
|
||||
}
|
||||
|
||||
function onDragFinished() {
|
||||
|
||||
recalculate();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user