---
id: "M:cAlgo.API.ChartArea.DrawIcon(System.String,cAlgo.API.ChartIconType,System.DateTime,System.Double,cAlgo.API.Color)"
kind: "method"
type: "T:cAlgo.API.ChartArea"
url: "https://help.ctrader.com/ctrader-algo/references/Chart/ChartArea/DrawIcon/"
---

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

# ChartArea.DrawIcon

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

## DrawIcon(string name, ChartIconType iconType, DateTime time, double y, Color color)

Draws an icon.

Environments: Desktop supported · CLI works differently · Cloud works differently.

- CLI: The object is created and returned, but never drawn: the CLI displays no chart.
- Cloud: The object is created and returned, but never drawn: the cloud displays no chart.

C#:

```csharp
ChartIcon DrawIcon(string name, ChartIconType iconType, DateTime time, double y, Color color)
```

Python:

```python
chartArea.DrawIcon(name: str, iconType: ChartIconType, time: DateTime, y: float, color: Color) -> ChartIcon
```

### Parameters

- `name` (`string`, Python `str`): The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name.
- `iconType` (`ChartIconType`, Python `ChartIconType`): The type of the icon.
- `time` (`DateTime`, Python `DateTime`): The time value of the icon location on the X-axis.
- `y` (`double`, Python `float`): The Y-axis value of the icon location.
- `color` (`Color`, Python `Color`): The color of the icon.

### Returns

`ChartIcon` — ChartIcon.

### Examples

C#:

```csharp
var icon = Chart.DrawIcon("buySignal", ChartIconType.UpArrow, Bars.OpenTimes.LastValue, Bars.LowPrices.LastValue, Color.Green);
Print("Icon drawn at {0}", icon.Time);
```

Python:

```python
icon = api.Chart.DrawIcon("buySignal", ChartIconType.UpArrow, api.Bars.OpenTimes.LastValue, api.Bars.LowPrices.LastValue, Color.Green)
api.Print(f"Icon drawn at {icon.Time}")
```

## DrawIcon(string name, ChartIconType iconType, int barIndex, double y, Color color)

Draws an icon.

Environments: Desktop supported · CLI works differently · Cloud works differently.

- CLI: The object is created and returned, but never drawn: the CLI displays no chart.
- Cloud: The object is created and returned, but never drawn: the cloud displays no chart.

C#:

```csharp
ChartIcon DrawIcon(string name, ChartIconType iconType, int barIndex, double y, Color color)
```

Python:

```python
chartArea.DrawIcon(name: str, iconType: ChartIconType, barIndex: int, y: float, color: Color) -> ChartIcon
```

### Parameters

- `name` (`string`, Python `str`): The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name.
- `iconType` (`ChartIconType`, Python `ChartIconType`): Type of the icon.
- `barIndex` (`int`, Python `int`): The bar index of the icon location on the X-axis.
- `y` (`double`, Python `float`): The Y-axis value of the icon location.
- `color` (`Color`, Python `Color`): The color of the icon.

### Returns

`ChartIcon` — ChartIcon.

### Examples

C#:

```csharp
// Draw an icon on the last bar high.
var index = Bars.Count - 1;
var icon = Chart.DrawIcon("highIcon", ChartIconType.Star, index, Bars.HighPrices[index], Color.Gold);

Print("Icon drawn at {0}", icon.Y);
```

Python:

```python
index = api.Bars.Count - 1
icon = api.Chart.DrawIcon("highIcon", ChartIconType.Star, index, api.Bars.HighPrices[index], Color.Gold)
api.Print(f"Icon drawn at {icon.Y}")
```

