improved indicator redraw on new candles with error handling
This commit is contained in:
@ -842,30 +842,31 @@ export function updateIndicatorCandles() {
|
||||
|
||||
// Chart drawing
|
||||
export function drawIndicatorsOnChart() {
|
||||
if (!window.dashboard || !window.dashboard.chart) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentInterval = window.dashboard.currentInterval;
|
||||
const candles = window.dashboard?.allData?.get(currentInterval);
|
||||
|
||||
if (!candles || candles.length === 0) {
|
||||
console.log('[Indicators] No candles available');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[Indicators] ========== drawIndicatorsOnChart START ==========`);
|
||||
console.log(`[Indicators] Candles from allData: ${candles.length}`);
|
||||
console.log(`[Indicators] First candle time: ${candles[0]?.time} (${new Date(candles[0]?.time * 1000).toLocaleDateString()})`);
|
||||
console.log(`[Indicators] Last candle time: ${candles[candles.length - 1]?.time} (${new Date(candles[candles.length - 1]?.time * 1000).toLocaleDateString()})`);
|
||||
|
||||
const oldestTime = candles[0]?.time;
|
||||
const newestTime = candles[candles.length - 1]?.time;
|
||||
const oldestDate = oldestTime ? new Date(oldestTime * 1000).toLocaleDateString() : 'N/A';
|
||||
const newestDate = newestTime ? new Date(newestTime * 1000).toLocaleDateString() : 'N/A';
|
||||
|
||||
console.log(`[Indicators] ========== Redrawing ==========`);
|
||||
console.log(`[Indicators] Candles: ${candles.length} | Time range: ${oldestDate} (${oldestTime}) to ${newestDate} (${newestTime})`);
|
||||
try {
|
||||
if (!window.dashboard || !window.dashboard.chart) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentInterval = window.dashboard.currentInterval;
|
||||
const candles = window.dashboard?.allData?.get(currentInterval);
|
||||
|
||||
if (!candles || candles.length === 0) {
|
||||
console.log('[Indicators] No candles available');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[Indicators] ========== drawIndicatorsOnChart START ==========`);
|
||||
console.log(`[Indicators] Candles from allData: ${candles.length}`);
|
||||
console.log(`[Indicators] First candle time: ${candles[0]?.time} (${new Date(candles[0]?.time * 1000).toLocaleDateString()})`);
|
||||
console.log(`[Indicators] Last candle time: ${candles[candles.length - 1]?.time} (${new Date(candles[candles.length - 1]?.time * 1000).toLocaleDateString()})`);
|
||||
|
||||
const oldestTime = candles[0]?.time;
|
||||
const newestTime = candles[candles.length - 1]?.time;
|
||||
const oldestDate = oldestTime ? new Date(oldestTime * 1000).toLocaleDateString() : 'N/A';
|
||||
const newestDate = newestTime ? new Date(newestTime * 1000).toLocaleDateString() : 'N/A';
|
||||
|
||||
console.log(`[Indicators] ========== Redrawing ==========`);
|
||||
console.log(`[Indicators] Candles: ${candles.length} | Time range: ${oldestDate} (${oldestTime}) to ${newestDate} (${newestTime})`);
|
||||
|
||||
const activeIndicators = getActiveIndicators();
|
||||
|
||||
@ -950,6 +951,9 @@ console.log(`[Indicators] ========== Redrawing ==========`);
|
||||
});
|
||||
|
||||
console.log(`[Indicators] ========== drawIndicatorsOnChart END ==========`);
|
||||
} catch (error) {
|
||||
console.error('[Indicators] Error drawing indicators:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function resetIndicator(id) {
|
||||
|
||||
Reference in New Issue
Block a user