---
id: "P:cAlgo.API.Control.ForegroundColor"
kind: "property"
type: "T:cAlgo.API.Control"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/Control/ForegroundColor/"
---

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

# Control.ForegroundColor

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

## ForegroundColor

Gets or sets the color of the chart control foreground. Check the Color class for the ARGB (alpha, red, green, blue) color values, or use the strings Color.Red, Color.FromName("Red"), Color.FromArgb(255, 0, 0), Color.FromHex("#ff0000"), "Red", "#ff0000".

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

- CLI: Accepted without error but never displayed, so control events such as Click are never raised.
- Cloud: Accepted without error but never displayed, so control events such as Click are never raised.

C#:

```csharp
public Color ForegroundColor {get; set;}
```

Python:

```python
control.ForegroundColor: Color
```

### Returns

`Color` — 

### Examples

C#:

```csharp
var profit = Positions.Sum(position => position.NetProfit);
var textBlock = new TextBlock { Text = "Net profit: " + profit.ToString("F2") };
textBlock.ForegroundColor = profit >= 0 ? Color.LimeGreen : Color.Red;
Chart.AddControl(textBlock);
```

Python:

```python
profit = sum(position.NetProfit for position in api.Positions)
textBlock = TextBlock()
textBlock.Text = f"Net profit: {profit:.2f}"
textBlock.ForegroundColor = Color.LimeGreen if profit >= 0 else Color.Red
api.Chart.AddControl(textBlock)
```

