> For the complete documentation index, see [llms.txt](https://fto-2.gitbook.io/fto-indicators-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fto-2.gitbook.io/fto-indicators-docs/api-reference/objects/properties-text-and-anchors/set-object-property.md).

# SetObjectProperty

Writes a simple or indexed property on a named chart object.

## Signature

```typescript
SetObjectProperty(...args: SetObjectPropertyArgs): boolean | null
```

## Parameters

| Name      | Type                    | Required | Description                                              |
| --------- | ----------------------- | -------- | -------------------------------------------------------- |
| `...args` | `SetObjectPropertyArgs` | Yes      | Arguments matching one of the expanded call forms below. |

## Returns

`true` on success, `false` when the object is absent, or `null` when no chart is attached.

## Usage

* Without `propModifier`, writes the property directly. With a zero-based modifier, only `ObjectProperty.TIME`, `PRICE`, and `LEVEL_VALUE` are supported.
* Raises an object error for invalid modified properties or invalid point/level indexes. A polyline can expand up to 100 points when setting an indexed point.

Time input matrix:

| Property form                                       | `FTODate` input           | Numeric input                                                        |
| --------------------------------------------------- | ------------------------- | -------------------------------------------------------------------- |
| `TIME1`, `TIME2`, or `TIME3` without `propModifier` | Supported and recommended | Internal chart date-time value, **not** Unix seconds or milliseconds |
| Indexed `ObjectProperty.TIME` with `propModifier`   | Supported and recommended | Unix milliseconds                                                    |

Alignment and anchor values are numeric codes, but they control different things. `ObjectProperty.HALIGNMENT` and `ObjectProperty.VALIGNMENT` align a drawing object's text annotation where supported; they do not position the object itself and have no effect on a standalone `ObjectType.TEXT` object. `ObjectProperty.ANCHOR_POINT` selects which point of a text or arrow object sits on its chart anchor. Use local constants for the values:

Object anchor (`ObjectProperty.ANCHOR_POINT`, text and arrow objects):

| Value | Pin           |
| ----- | ------------- |
| `0`   | Left top      |
| `1`   | Left center   |
| `2`   | Left bottom   |
| `3`   | Center bottom |
| `4`   | Right bottom  |
| `5`   | Right center  |
| `6`   | Right top     |
| `7`   | Center top    |
| `8`   | Center        |

Text annotation, horizontal alignment (`ObjectProperty.HALIGNMENT`): `0` left, `1` center, `2` right.

Text annotation, vertical alignment (`ObjectProperty.VALIGNMENT`): `0` top, `1` center, `2` bottom.

`HALIGNMENT` and `VALIGNMENT` cannot be read back — `GetObjectNumberProperty` returns `0` for them regardless of what you set.

Expanded call forms:

* `SetObjectProperty(chartId: number, name: string, propId: ObjectProperty, value: any, isStatic?: boolean): boolean | null`
* `SetObjectProperty(chartId: number, name: string, propId: ObjectProperty, propModifier: number, value: any, isStatic?: boolean): boolean | null`

## Example

```typescript
const objectName = 'MyIndicator_Label'
const ANCHOR_CENTER_BOTTOM = 3
const HALIGN_RIGHT = 2
const VALIGN_TOP = 0

this.api.SetObjectProperty(0, objectName, ObjectProperty.COLOR, '#2962FF', true)
this.api.SetObjectProperty(0, objectName, ObjectProperty.PRICE, 0, this.api.Close(0), true)
// Position the text or arrow object relative to its chart anchor.
this.api.SetObjectProperty(0, 'swing-high', ObjectProperty.ANCHOR_POINT, ANCHOR_CENTER_BOTTOM)
// Align text annotations on drawing objects that support them.
this.api.SetObjectProperty(0, 'level-note', ObjectProperty.HALIGNMENT, HALIGN_RIGHT)
this.api.SetObjectProperty(0, 'zone-note', ObjectProperty.VALIGNMENT, VALIGN_TOP)
```

## Related API

* [GetObjectProperty](/fto-indicators-docs/api-reference/objects/properties-text-and-anchors/get-object-property.md)
* [MoveObjectPoint](/fto-indicators-docs/api-reference/objects/properties-text-and-anchors/move-object-point.md)
* [Chart-object cleanup](/fto-indicators-docs/api-reference/objects/creation-and-cleanup/chart-object-cleanup.md)
* [ObjectProperty](/fto-indicators-docs/api-reference/types/chart-objects-and-appearance/object-property.md)
