As far as I am aware, there is no function that gets called when an (custom) indicator gets removed from a chart. This means there’s no way to clean up chart objects that were created by the indicator and they are left on the chart until the user cleans them up manually or pressing hide first before removing the custom indicator. Either calling the already existing OnHide method on removal, or a new method named Cleanup would solve this. A bare bones example might look like:
class MyCustomIndicator extends IndicatorImplementation {
private objects: string[] = []
public Init(): void {
// initialize
}
public Cleanup(): void {
// called when indicator is removed from chart
for (let id of this.objects) {
this.api.RemoveChartObject(id)
}
}
public Calculate(index: number): void {
let name = getUniqueName()
this.api.CreateChartObject(name, ...)
// save name for clean up later
this.objects.push(name)
}
}This is a minor annoyance but can cause performance issues if objects aren’t cleaned up and continue to accumulate.
In Review
💡 Feature Request
4 months ago

User
Get notified by email when there are changes.
In Review
💡 Feature Request
4 months ago

User
Get notified by email when there are changes.