RemoveAllObjectsByPrefix

Removes all chart objects whose names start with a specified prefix.

Syntax

RemoveAllObjectsByPrefix(prefix: string, isStatic?: boolean, window?: number): void

Parameters

Parameter
Type
Description

prefix

string

Name prefix to match. Matching is case-sensitive. Empty prefix removes all objects.

isStatic

boolean

Optional. Whether to remove static objects (default: false)

window

number

Optional. Target window: 0 = MainChart, 1+ = OscWin. Default: current chart

Description

The RemoveAllObjectsByPrefix method removes all chart objects whose names begin with the given prefix. This is useful for cleaning up objects created with a common naming convention (e.g. "MyStrategy_Line_1", "MyStrategy_Line_2").

Example

// Remove all objects with names starting with "MyStrategy_"
this.api.RemoveAllObjectsByPrefix("MyStrategy_");

// Remove all static objects with prefix "Label"
this.api.RemoveAllObjectsByPrefix("Label", true);

// Remove all objects with prefix from MainChart
this.api.RemoveAllObjectsByPrefix("Temp_", false, 0);

Last updated