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:
DiTus
2026-02-26 15:14:34 +01:00
parent 2769814b64
commit 3a8040590b
2 changed files with 20 additions and 19 deletions

View File

@ -542,23 +542,7 @@ async loadTA() {
</span> </span>
</div> </div>
</div> </div>
<div class="ta-section">
<div class="ta-section-title">Indicators</div>
<div id="indicatorList" class="indicator-list"></div>
</div>
<div class="ta-section" id="indicatorConfigPanel">
<div class="ta-section-title">Configuration</div>
<div id="configForm" style="margin-top: 8px;"></div>
<div style="display: flex; gap: 8px; margin-top: 12px;" id="configButtons">
<button class="ta-btn" onclick="applyIndicatorConfig()" style="flex: 1; font-size: 11px; background: var(--tv-blue); color: white; border: none;">Apply</button>
<button class="ta-btn" onclick="removeIndicator()" style="flex: 1; font-size: 11px; border-color: var(--tv-red); color: var(--tv-red);">Remove</button>
</div>
</div>
`; `;
window.renderIndicatorList?.();
} }
async loadStats() { async loadStats() {

View File

@ -496,15 +496,26 @@ window.clearAllIndicators = function() {
} }
function removeIndicatorById(id) { 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); 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 => { activeIndicators[idx].series?.forEach(s => {
try { window.dashboard?.chart?.removeSeries(s); } catch(e) {} try { window.dashboard?.chart?.removeSeries(s); } catch(e) {}
}); });
// Remove the specific indicator, don't clear the whole array
activeIndicators.splice(idx, 1); activeIndicators.splice(idx, 1);
console.log(`[removeIndicatorById] After removal, array now has ${activeIndicators.length} indicators`);
if (configuringId === id) { if (configuringId === id) {
configuringId = null; configuringId = null;
} }
@ -794,6 +805,12 @@ export function drawIndicatorsOnChart() {
return; 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 currentInterval = window.dashboard.currentInterval;
const candles = window.dashboard.allData.get(currentInterval); const candles = window.dashboard.allData.get(currentInterval);