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:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user