> 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/access_to_objects/does-chart-object-exist.md).

# DoesChartObjectExist

Checks if a chart object with the specified name exists.

## Syntax

```typescript
DoesChartObjectExist(uniqueObjectName: string, isStatic: boolean = false): boolean
```

## Parameters

| Parameter        | Type    | Description                                                |
| ---------------- | ------- | ---------------------------------------------------------- |
| uniqueObjectName | string  | The unique name of the object to check                     |
| isStatic         | boolean | Optional. Whether to check static objects (default: false) |

## Return Value

Returns a `boolean` indicating whether the object exists (`true`) or not (`false`).

## Description

The `DoesChartObjectExist` method checks for the existence of a chart object with the specified name. It can check for both regular and static objects, depending on the `isStatic` parameter.

## Example

```typescript
// Check if object exists before using it
if (this.api.DoesChartObjectExist("MyTrendLine")) {
  // Object exists, safe to use
  this.api.SetObjectProperty("MyTrendLine", ObjProp.OBJPROP_COLOR, 0xff0000);
} else {
  console.log("Object not found");
}

// Check static object
const staticExists = this.api.DoesChartObjectExist("MyStaticLabel", true);
console.log(`Static object exists: ${staticExists}`);

// Create object only if it doesn't exist
const objectName = "UniqueObject";
if (!this.api.DoesChartObjectExist(objectName)) {
  this.api.СreateChartObject(
    objectName,
    TObjectType.TEXT,
    0,
    this.api.createFTODate(Date.now()),
    1.2345
  );
}

// Remove object if it exists
if (this.api.DoesChartObjectExist("OldObject")) {
  this.api.RemoveChartObject("OldObject");
}
```
