---
id: "M:cAlgo.API.Indicator.SetBarColor(cAlgo.API.IndicatorBarOutput,System.Int32,cAlgo.API.Color)"
kind: "method"
type: "T:cAlgo.API.Indicator"
url: "https://help.ctrader.com/ctrader-algo/references/General/Indicator/SetBarColor/"
---

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

# Indicator.SetBarColor

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

## SetBarColor(IndicatorBarOutput barOutput, int barIndex, Color outlineColor)

Sets appearance of an indicator bar output from startIndex to last index.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: No effect; arguments are still validated (ArgumentException when all colours are null).
- Cloud: No effect; arguments are still validated (ArgumentException when all colours are null).

C#:

```csharp
protected void SetBarColor(IndicatorBarOutput barOutput, int barIndex, Color outlineColor)
```

Python:

```python
api.SetBarColor(barOutput: IndicatorBarOutput, barIndex: int, outlineColor: Color) -> None
```

### Parameters

- `barOutput` (`IndicatorBarOutput`, Python `IndicatorBarOutput`): Indicator Bar Output
- `barIndex` (`int`, Python `int`): Bar Index
- `outlineColor` (`Color`, Python `Color`): Outline Color

Available since cAlgo.API 5.4.

### Examples

C#:

```csharp
public partial class ColoredBars : Indicator
{
    public override void Calculate(int index)
    {
        var bar = Bars[index];
        Result[index] = new OhlcvBar(bar.Open, bar.High, bar.Low, bar.Close, bar.TickVolume);
        var outlineColor = bar.Close >= bar.Open ? Color.Green : Color.Red;
        SetBarColor(Result.Output, index, outlineColor);
    }
}
```

Python:

```python
def calculate(self, index):
    bar = api.Bars[index]
    api.Result[index] = OhlcvBar(bar.Open, bar.High, bar.Low, bar.Close, bar.TickVolume)
    outlineColor = Color.Green if bar.Close >= bar.Open else Color.Red
    api.SetBarColor(api.Result.Output, index, outlineColor)
```

config.json:

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

## SetBarColor(IndicatorBarOutput barOutput, int barIndex, Color outlineColor, Color fillColor)

Sets appearance of an indicator bar output from startIndex to startIndex + count.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: No effect; arguments are still validated (ArgumentException when all colours are null).
- Cloud: No effect; arguments are still validated (ArgumentException when all colours are null).

C#:

```csharp
protected void SetBarColor(IndicatorBarOutput barOutput, int barIndex, Color outlineColor, Color fillColor)
```

Python:

```python
api.SetBarColor(barOutput: IndicatorBarOutput, barIndex: int, outlineColor: Color, fillColor: Color) -> None
```

### Parameters

- `barOutput` (`IndicatorBarOutput`, Python `IndicatorBarOutput`): Indicator Bar Output
- `barIndex` (`int`, Python `int`): Bar Index
- `outlineColor` (`Color`, Python `Color`): Outline Color
- `fillColor` (`Color`, Python `Color`): Fill Color

Available since cAlgo.API 5.4.

### Examples

C#:

```csharp
public partial class ColoredBars : Indicator
{
    public override void Calculate(int index)
    {
        var bar = Bars[index];
        Result[index] = new OhlcvBar(bar.Open, bar.High, bar.Low, bar.Close, bar.TickVolume);
        var color = bar.Close >= bar.Open ? Color.Green : Color.Red;
        SetBarColor(Result.Output, index, color, Color.FromArgb(80, color));
    }
}
```

Python:

```python
def calculate(self, index):
    bar = api.Bars[index]
    api.Result[index] = OhlcvBar(bar.Open, bar.High, bar.Low, bar.Close, bar.TickVolume)
    color = Color.Green if bar.Close >= bar.Open else Color.Red
    api.SetBarColor(api.Result.Output, index, color, Color.FromArgb(80, color))
```

config.json:

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

## SetBarColor(IndicatorBarOutput barOutput, int barIndex, Color outlineColor, Color fillColor, Color volumeColor)

Sets appearance of an indicator bar output from startIndex to last index.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: No effect; arguments are still validated (ArgumentException when all colours are null).
- Cloud: No effect; arguments are still validated (ArgumentException when all colours are null).

C#:

```csharp
protected void SetBarColor(IndicatorBarOutput barOutput, int barIndex, Color outlineColor, Color fillColor, Color volumeColor)
```

Python:

```python
api.SetBarColor(barOutput: IndicatorBarOutput, barIndex: int, outlineColor: Color, fillColor: Color, volumeColor: Color) -> None
```

### Parameters

- `barOutput` (`IndicatorBarOutput`, Python `IndicatorBarOutput`): Indicator Bar Output
- `barIndex` (`int`, Python `int`): Bar Index
- `outlineColor` (`Color`, Python `Color`): Outline Color
- `fillColor` (`Color`, Python `Color`): Fill Color
- `volumeColor` (`Color`, Python `Color`): Volume color

Available since cAlgo.API 5.4.

### Examples

C#:

```csharp
public partial class ColoredBars : Indicator
{
    public override void Calculate(int index)
    {
        var bar = Bars[index];
        Result[index] = new OhlcvBar(bar.Open, bar.High, bar.Low, bar.Close, bar.TickVolume);
        var color = bar.Close >= bar.Open ? Color.Green : Color.Red;
        SetBarColor(Result.Output, index, color, Color.FromArgb(80, color), Color.Gray);
    }
}
```

Python:

```python
def calculate(self, index):
    bar = api.Bars[index]
    api.Result[index] = OhlcvBar(bar.Open, bar.High, bar.Low, bar.Close, bar.TickVolume)
    color = Color.Green if bar.Close >= bar.Open else Color.Red
    api.SetBarColor(api.Result.Output, index, color, Color.FromArgb(80, color), Color.Gray)
```

config.json:

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

