---
id: "M:cAlgo.API.Indicator.OnDestroy"
kind: "method"
type: "T:cAlgo.API.Indicator"
url: "https://help.ctrader.com/ctrader-algo/references/General/Indicator/OnDestroy/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# Indicator.OnDestroy

Member of [Indicator](https://help.ctrader.com/ctrader-algo/references/General/Indicator/index.md).

## OnDestroy()

Called when Indicator is destroyed.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
protected internal void OnDestroy()
```

Python:

```python
api.OnDestroy() -> None
```

### Examples

C#:

```csharp
protected override void OnDestroy()
{
    Print("Indicator destroyed after {0} bars", Bars.Count);
}

public override void Calculate(int index)
{
}
```

Python:

```python
def on_destroy(self):
    api.Print(f"Indicator destroyed after {api.Bars.Count} bars")
```

