diff --git a/src/api/dashboard/static/js/ui/indicators-panel-new.js b/src/api/dashboard/static/js/ui/indicators-panel-new.js index d083b21..06d00ac 100644 --- a/src/api/dashboard/static/js/ui/indicators-panel-new.js +++ b/src/api/dashboard/static/js/ui/indicators-panel-new.js @@ -579,6 +579,40 @@ window.applyPresetFromWindow = function(presetId) { applyPreset(indicator.id, presetId); }; +function addIndicator(type) { + const IndicatorClass = IR?.[type]; + if (!IndicatorClass) return; + + const id = `${type}_${nextInstanceId++}`; + const instance = new IndicatorClass({ type, params: {}, name: '' }); + const metadata = instance.getMetadata(); + + const params = { + _lineType: 'solid', + _lineWidth: 2 + }; + metadata.plots.forEach((plot, idx) => { + params[`_color_${idx}`] = plot.color || getDefaultColor(activeIndicators.length + idx); + }); + metadata.inputs.forEach(input => { + params[input.name] = input.default; + }); + + activeIndicators.push({ + id, + type, + name: metadata.name, + params, + plots: metadata.plots, + series: [], + visible: true + }); + + configuringId = id; + renderIndicatorPanel(); + drawIndicatorsOnChart(); +}; + function saveUserPresets() { localStorage.setItem('indicator_presets', JSON.stringify(userPresets)); } @@ -751,7 +785,6 @@ window.applyIndicatorConfig = function() { }; // Assign functions to window for backward compatibility -window.addIndicator = window.addIndicator || addIndicator; window.removeIndicator = function() { if (!configuringId) return; removeIndicatorById(configuringId);