---
id: "T:cAlgo.API.LevelsAttribute"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Attributes/LevelsAttribute/"
---

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

# LevelsAttribute (class)

Levels Attribute. Applies metadata to enable the plot of level lines.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public sealed class LevelsAttribute : Attribute
```

## Remarks

Represents level lines. It is commonly used in Oscillators, for instance to add a zero line. C# and Python indicators declare their levels the same way, with the Levels entry of config.json.

## Examples

C#:

```csharp
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    // This sample indicator sets levels on its outputs with the Levels entry of config.json
    public partial class LevelsSample : Indicator
    {
        private RelativeStrengthIndex _rsi;

        protected override void Initialize()
        {
            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 14);
        }

        public override void Calculate(int index)
        {
            Result[index] = _rsi.Result[index];
        }
    }
}
```

Python:

```python
class LevelsSample():
    def initialize(self):
        self.rsi = api.Indicators.RelativeStrengthIndex(api.Bars.ClosePrices, 14)

    def calculate(self, index):
        api.Result[index] = self.rsi.Result[index]
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": false,
  "LineOutputs": [
    {
      "Name": "Result",
      "DisplayName": "Main"
    }
  ],
  "Levels": [
    30,
    70
  ]
}
```

## Constructors

- `public LevelsAttribute(double[] levels)` — Initializes a new LevelsAttribute instance [details](https://help.ctrader.com/ctrader-algo/references/Attributes/LevelsAttribute/Constructor/index.md)

## Properties

- `public double[] Levels {get; set;}` — The array of price values that are ploted as level lines [details](https://help.ctrader.com/ctrader-algo/references/Attributes/LevelsAttribute/Levels/index.md)

