Restore missing addIndicator function that was accidentally deleted

The addIndicator function definition was missing from the file, causing window.addIndicator
to reference itself in a circular reference. Added back the full function definition
and removed the problematic circular reference assignment.
This commit is contained in:
DiTus
2026-02-25 23:07:18 +01:00
parent ee7bfc9571
commit 0b6d5a04ee

View File

@ -579,6 +579,40 @@ window.applyPresetFromWindow = function(presetId) {
applyPreset(indicator.id, 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() { function saveUserPresets() {
localStorage.setItem('indicator_presets', JSON.stringify(userPresets)); localStorage.setItem('indicator_presets', JSON.stringify(userPresets));
} }
@ -751,7 +785,6 @@ window.applyIndicatorConfig = function() {
}; };
// Assign functions to window for backward compatibility // Assign functions to window for backward compatibility
window.addIndicator = window.addIndicator || addIndicator;
window.removeIndicator = function() { window.removeIndicator = function() {
if (!configuringId) return; if (!configuringId) return;
removeIndicatorById(configuringId); removeIndicatorById(configuringId);