# CreateChartObject

Creates a new chart object with specified parameters.

## Syntax

```typescript
С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   | [TObjectType](/fto-indicators-docs/types/object-type.md) | Type of object to create (e.g., trend line, rectangle)                                   |
| window    | number                                                   | Chart window: `0` = MainChart, `1+` = OscWin. Object is created in the specified window. |
| ftoDate1  | [FTODate](/fto-indicators-docs/fto-date.md)              | First time coordinate                                                                    |
| price1    | number                                                   | First price coordinate                                                                   |
| ftoDate2  | [FTODate](/fto-indicators-docs/fto-date.md)              | Optional. Second time coordinate (required for some objects)                             |
| price2    | number                                                   | Optional. Second price coordinate (required for some objects)                            |
| ftoDate3  | [FTODate](/fto-indicators-docs/fto-date.md)              | 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

## Examples

### Text Object

```typescript
// Create text object
this.api.CreateChartObject('MyLabel', TObjectType.TEXT, 0, this.api.Time(0), this.api.Close(0))

// Set text content and styling
this.api.SetObjectProperty('MyLabel', ObjProp.OBJPROP_TEXT, 'Support Level')
this.api.SetObjectProperty('MyLabel', ObjProp.OBJPROP_FONTNAME, 'Arial')
this.api.SetObjectProperty('MyLabel', ObjProp.OBJPROP_FONTSIZE, 12)
this.api.SetObjectProperty('MyLabel', ObjProp.OBJPROP_COLOR, '#0000FF')
this.api.SetObjectProperty('MyLabel', ObjProp.OBJPROP_ANCHOR_POINT, AnchorPoint.CENTER)
```

### Rectangle Object

```typescript
// Create rectangle
this.api.CreateChartObject(
    'MyRectangle',
    TObjectType.RECTANGLE,
    0,
    this.api.Time(10),
    this.api.Close(10),
    this.api.Time(0),
    this.api.Close(0)
)

// Set rectangle styling
this.api.SetObjectProperty('MyRectangle', ObjProp.OBJPROP_COLOR, '#00FF00')
this.api.SetObjectProperty('MyRectangle', ObjProp.OBJPROP_FILLCOLOR, '#00FF0020')
this.api.SetObjectProperty('MyRectangle', ObjProp.OBJPROP_FILLINSIDE, true)
this.api.SetObjectProperty('MyRectangle', ObjProp.OBJPROP_WIDTH, 1)
this.api.SetObjectProperty('MyRectangle', ObjProp.OBJPROP_BACK, true)
this.api.SetObjectProperty('MyRectangle', ObjProp.OBJPROP_MIDDLE_LINE, true)

// Set text content and styling for rectangle
this.api.SetObjectProperty('MyRectangle', ObjProp.OBJPROP_TEXT, 'Text')
this.api.SetObjectProperty('MyRectangle', ObjProp.OBJPROP_FONTNAME, 'Arial')
this.api.SetObjectProperty('MyRectangle', ObjProp.OBJPROP_FONTSIZE, 12)
```

### Fixed Object (Screen Coordinates)

```typescript
// Create a text object with screen coordinates
this.api.CreateChartObject('FixedLabel', TObjectType.TEXT, 0, 0, 0)

// Enable screen coordinates mode
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_SCREENCOORDS, true)

// Set fixed position relative to chart corner (top-left)
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_XDISTANCE, 50) // 50 pixels from left
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_YDISTANCE, 30) // 30 pixels from top

// Set fixed size
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_XSIZE, 200) // 200 pixels wide
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_YSIZE, 40) // 40 pixels tall

// Configure text properties
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_TEXT, 'Fixed Position Label')
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_FONTNAME, 'Arial')
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_FONTSIZE, 14)
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_COLOR, '#333333')
this.api.SetObjectProperty('FixedLabel', ObjProp.OBJPROP_ANCHOR_POINT, AnchorPoint.LEFT_TOP)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fto-2.gitbook.io/fto-indicators-docs/access_to_objects/create-chart-object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
