GetObjectProperty
Retrieves a property value from a chart object.
Syntax
GetObjectProperty(
name: string,
index: ObjProp | number,
isStatic: boolean = false
): number | string
Parameters
Parameter
Type
Description
name
string
The name of the object
isStatic
boolean
Optional. Whether the object is static (default: false)
Return Value
Returns either a number
or string
depending on the property type.
Description
The GetObjectProperty
method retrieves a property value from a specified chart object. It can return either numeric or string properties depending on the property identifier provided.
See ObjProp for a complete list of available object properties.
Example
// Get object coordinates
const time1 = this.api.GetObjectProperty("MyTrendLine", ObjProp.OBJPROP_TIME1);
const price1 = this.api.GetObjectProperty(
"MyTrendLine",
ObjProp.OBJPROP_PRICE1
);
console.log(`First point: Time=${time1}, Price=${price1}`);
// Get object color
const color = this.api.GetObjectProperty("MyTrendLine", ObjProp.OBJPROP_COLOR);
console.log(`Object color: ${color}`);
// Get text content
const text = this.api.GetObjectProperty("MyLabel", ObjProp.OBJPROP_TEXT);
console.log(`Label text: ${text}`);
Last updated