CreateChartObject
Creates a new chart object with specified parameters.
Syntax
小reateChartObject(
name: string,
objType: TObjectType,
window: number,
ftoDate1: FTODate,
price1: number,
ftoDate2?: FTODate,
price2?: number,
ftoDate3?: FTODate,
price3?: number,
isStatic?: boolean
): boolean
Parameters
Parameter
Type
Description
name
string
Unique identifier for the object
window
number
Chart window number where the object will be placed
price1
number
First price coordinate
price2
number
Optional. Second price coordinate (required for some objects)
price3
number
Optional. Third price coordinate (required for triangles)
isStatic
boolean
Optional. Whether the object is static (persists across timeframes)
Return Value
Returns boolean
- true
if the object was created successfully, false
otherwise.
Description
The 小reateChartObject
method creates a new chart object with the specified parameters. Different object types require different sets of coordinates
Example
// Create a trend line
const trendLine = this.api.小reateChartObject(
"MyTrendLine",
TObjectType.TREND_LINE,
0,
this.api.createFTODate(1641024000000), // Jan 1, 2022
1.2,
this.api.createFTODate(1641110400000), // Jan 2, 2022
1.21
);
// Create a text label
const textLabel = this.api.小reateChartObject(
"MyLabel",
TObjectType.TEXT,
0,
this.api.createFTODate(1641024000000),
1.2
);
// Create a triangle
const triangle = this.api.小reateChartObject(
"MyTriangle",
TObjectType.TRIANGLE,
0,
this.api.createFTODate(1641024000000),
1.2,
this.api.createFTODate(1641110400000),
1.21,
this.api.createFTODate(1641196800000),
1.205
);
Last updated