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

objType

Type of object to create (e.g., trend line, rectangle)

window

number

Chart window number where the object will be placed

ftoDate1

First time coordinate

price1

number

First price coordinate

ftoDate2

Optional. Second time coordinate (required for some objects)

price2

number

Optional. Second price coordinate (required for some objects)

ftoDate3

Optional. Third time coordinate (required for triangles)

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