---
id: "M:cAlgo.API.LevelsAttribute.#ctor(System.Double[])"
kind: "constructor"
type: "T:cAlgo.API.LevelsAttribute"
url: "https://help.ctrader.com/ctrader-algo/references/Attributes/LevelsAttribute/Constructor/"
---

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

# LevelsAttribute constructor

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

## LevelsAttribute(double[] levels)

Initializes a new LevelsAttribute instance

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public LevelsAttribute(double[] levels)
```

Python:

```python
LevelsAttribute(levels: list[float])
```

### Parameters

- `levels` (`double[]`, Python `list[float]`): The price values that the level lines are representing

### Examples

C#:

```csharp
public partial class MomentumSample : Indicator
{
    public override void Calculate(int index)
    {
        Result[index] = Bars.ClosePrices[index] - Bars.ClosePrices[index - 10];
    }
}
```

Python:

```python
def calculate(self, index):
    api.Result[index] = api.Bars.ClosePrices[index] - api.Bars.ClosePrices[index - 10]
```

config.json:

```json
{
  "AccessRights": "None",
  "IsOverlay": false,
  "LineOutputs": [
    {
      "Name": "Result",
      "DisplayName": "Main"
    }
  ],
  "Levels": [
    0
  ]
}
```

