The Fix
The solution is identical to the previous examples: add the object cleanup logic to the very beginning of the OnInit() function. This ensures that every time the indicator loads, it starts with a completely clean slate.
Define Object Prefix: The OnInit() function first defines the unique obj_prefix.
Delete Old Objects: We will add ObjectsDeleteAll(0, obj_prefix); right after the prefix is defined. This command will find and delete all objects from any previous instance of this indicator on the chart.
Redraw Chart: A ChartRedraw() call makes the deletion visually immediate.
This small addition makes your code robust and prevents any "ghost" objects from remaining on the chart.