---
id: "M:cAlgo.API.Internals.IIndicatorsAccessor.CenterOfGravity(System.Int32)"
kind: "method"
type: "T:cAlgo.API.Internals.IIndicatorsAccessor"
url: "https://help.ctrader.com/ctrader-algo/references/Indicators/IIndicatorsAccessor/CenterOfGravity/"
---

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

# IIndicatorsAccessor.CenterOfGravity

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

## CenterOfGravity(int length)

The Center of Gravity (COG) indicator is a technical indicator developed by John Ehlers in 2002, used to identify potential turning points in the price as early as possible.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
CenterOfGravity CenterOfGravity(int length)
```

Python:

```python
api.Indicators.CenterOfGravity(length: int) -> CenterOfGravity
```

### Parameters

- `length` (`int`, Python `int`): The length of CenterOfGravity

### Returns

`CenterOfGravity` — CenterOfGravity

### Examples

C#:

```csharp
var centerOfGravity = Indicators.CenterOfGravity(10);
Print("Center of Gravity: {0}, lag: {1}", centerOfGravity.Result.LastValue, centerOfGravity.Lag.LastValue);
```

Python:

```python
centerOfGravity = api.Indicators.CenterOfGravity(10)
api.Print(f"Center of Gravity: {centerOfGravity.Result.LastValue}, lag: {centerOfGravity.Lag.LastValue}")
```

