---
id: "M:cAlgo.API.Internals.IIndicatorsAccessor.GetIndicator``1(System.Object[])"
kind: "method"
type: "T:cAlgo.API.Internals.IIndicatorsAccessor"
url: "https://help.ctrader.com/ctrader-algo/references/Indicators/IIndicatorsAccessor/GetIndicator/"
---

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

# IIndicatorsAccessor.GetIndicator

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

## GetIndicator(object[] parameterValues)

Initializes the custom indicator

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
TIndicator GetIndicator(object[] parameterValues)
```

Python:

```python
api.Indicators.GetIndicator(parameterValues: list[object]) -> TIndicator
```

### Parameters

- `parameterValues` (`object[]`, Python `list[object]`): The custom indicator parameter values or an anonymous object that contains custom indicator parameter values.

### Returns

`TIndicator` — Custom indicator instance

### Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo
{
    // SampleSMA and SampleSmaBot are separate algo projects: the config.json tab is the SampleSMA indicator's,
    // and the cBot references the SampleSMA project
    public partial class SampleSMA : Indicator
    {
        private SimpleMovingAverage _sma;

        protected override void Initialize() => _sma = Indicators.SimpleMovingAverage(Source, Periods);

        public override void Calculate(int index) => Result[index] = _sma.Result[index];
    }

    public partial class SampleSmaBot : Robot
    {
        protected override void OnStart()
        {
            // Parameter values are passed in the order the custom indicator declares them
            var sampleSma = Indicators.GetIndicator<SampleSMA>(Bars.ClosePrices, 20);
            Print("SampleSMA: {0}", sampleSma.Result.LastValue);
        }
    }
}
```

Python:

```python
# The SampleSMA indicator project must be referenced by this algo; the config.json tab is SampleSMA's
sampleSma = api.GetIndicator("SampleSMA", api.Bars.ClosePrices, 20)
api.Print(f"SampleSMA: {sampleSma.Result.LastValue}")
```

config.json:

```json
{
  "AccessRights": "None",
  "Parameters": [
    {
      "Name": "Source",
      "Type": "DataSeries"
    },
    {
      "Name": "Periods",
      "Type": "Integer",
      "DefaultValue": 14
    }
  ],
  "LineOutputs": [
    {
      "Name": "Result",
      "DisplayName": "Main"
    }
  ]
}
```

## GetIndicator(Bars bars, object[] parameterValues)

Initializes the custom indicator

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
TIndicator GetIndicator(Bars bars, object[] parameterValues)
```

Python:

```python
api.Indicators.GetIndicator(bars: Bars, parameterValues: list[object]) -> TIndicator
```

### Parameters

- `bars` (`Bars`, Python `Bars`): The Bars that will be used by indicator, you can pass another timeframe/symbol bars
- `parameterValues` (`object[]`, Python `list[object]`): The custom indicator parameter values or an anonymous object that contains custom indicator parameter values.

### Returns

`TIndicator` — Custom indicator instance

### Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo
{
    // SampleSMA and DailySmaBot are separate algo projects: the config.json tab is the SampleSMA indicator's,
    // and the cBot references the SampleSMA project
    public partial class SampleSMA : Indicator
    {
        private SimpleMovingAverage _sma;

        protected override void Initialize() => _sma = Indicators.SimpleMovingAverage(Bars.ClosePrices, Periods);

        public override void Calculate(int index) => Result[index] = _sma.Result[index];
    }

    public partial class DailySmaBot : Robot
    {
        protected override void OnStart()
        {
            var dailyBars = MarketData.GetBars(TimeFrame.Daily);
            // The custom indicator is calculated on the daily bars instead of the chart bars
            var dailySma = Indicators.GetIndicator<SampleSMA>(dailyBars, 20);
            Print("Daily SMA(20): {0}", dailySma.Result.LastValue);
        }
    }
}
```

Python:

```python
# The SampleSMA indicator project must be referenced by this algo; the config.json tab is SampleSMA's
dailySma = api.GetIndicator("SampleSMA", api.MarketData.GetBars(TimeFrame.Daily), 20)
```

config.json:

```json
{
  "AccessRights": "None",
  "Parameters": [
    {
      "Name": "Periods",
      "Type": "Integer",
      "DefaultValue": 14
    }
  ],
  "LineOutputs": [
    {
      "Name": "Result",
      "DisplayName": "Main"
    }
  ]
}
```

