Fix: Prevent indicators from being deleted during TF switch
- Remove window.renderIndicatorList() call from renderTA() - This was triggering initIndicatorPanel during each TF switch - Added logging to removeIndicatorById to track unexpected deletions - Removed indicator configuration UI from TA panel (sidebar handles this now)
This commit is contained in:
@ -496,16 +496,27 @@ window.clearAllIndicators = function() {
|
||||
}
|
||||
|
||||
function removeIndicatorById(id) {
|
||||
console.log(`[removeIndicatorById] Attempting to remove indicator: ${id}`);
|
||||
console.log('Call stack:', console.trace());
|
||||
|
||||
const idx = activeIndicators.findIndex(a => a.id === id);
|
||||
if (idx < 0) return;
|
||||
if (idx < 0) {
|
||||
console.warn(`[removeIndicatorById] Indicator ${id} not found in array`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[removeIndicatorById] Removing indicator at index ${idx}`);
|
||||
|
||||
activeIndicators[idx].series?.forEach(s => {
|
||||
try { window.dashboard?.chart?.removeSeries(s); } catch(e) {}
|
||||
});
|
||||
|
||||
// Remove the specific indicator, don't clear the whole array
|
||||
activeIndicators.splice(idx, 1);
|
||||
|
||||
if (configuringId === id) {
|
||||
console.log(`[removeIndicatorById] After removal, array now has ${activeIndicators.length} indicators`);
|
||||
|
||||
if (configuringId === id) {
|
||||
configuringId = null;
|
||||
}
|
||||
|
||||
@ -794,6 +805,12 @@ export function drawIndicatorsOnChart() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeIndicators.length === 0) {
|
||||
console.error('⚠️ drawIndicatorsOnChart: activeIndicators is EMPTY!');
|
||||
console.error('⚠️ This means indicators were lost during TF switch!');
|
||||
console.trace('Call stack showing where we are:');
|
||||
}
|
||||
|
||||
const currentInterval = window.dashboard.currentInterval;
|
||||
const candles = window.dashboard.allData.get(currentInterval);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user