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

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

# ChartArea.DrawText

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

## DrawText(string name, string text, DateTime time, double y, Color color)

Draws the text.

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
ChartText DrawText(string name, string text, DateTime time, double y, Color color)
```

Python:

```python
chartArea.DrawText(name: str, text: str, time: DateTime, y: float, color: Color) -> ChartText
```

### 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.
- `text` (`string`, Python `str`): The text content.
- `time` (`DateTime`, Python `DateTime`): The time value of the text object location on the X-axis.
- `y` (`double`, Python `float`): The Y-axis value of the text object location.
- `color` (`Color`, Python `Color`): The color of the text.

### Returns

`ChartText` — ChartText.

### Examples

C#:

```csharp
// Draw the text on the last bar high.
var highPrice = Bars.HighPrices.LastValue;
var openTime = Bars.OpenTimes.LastValue;
var text = Chart.DrawText("text1", "High is here", openTime, highPrice, Color.Red);
text.VerticalAlignment = VerticalAlignment.Bottom;
text.HorizontalAlignment = HorizontalAlignment.Center;
```

Python:

```python
highPrice = api.Bars.HighPrices.LastValue
openTime = api.Bars.OpenTimes.LastValue
text = api.Chart.DrawText("text1", "High is here", openTime, highPrice, Color.Red)
text.VerticalAlignment = VerticalAlignment.Bottom
text.HorizontalAlignment = HorizontalAlignment.Center
```

## DrawText(string name, string text, int barIndex, double y, Color color)

Draws the text.

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
ChartText DrawText(string name, string text, int barIndex, double y, Color color)
```

Python:

```python
chartArea.DrawText(name: str, text: str, barIndex: int, y: float, color: Color) -> ChartText
```

### 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.
- `text` (`string`, Python `str`): The text content.
- `barIndex` (`int`, Python `int`): The bar index of the text object location on the X-axis.
- `y` (`double`, Python `float`): The Y-axis value of the text object location.
- `color` (`Color`, Python `Color`): The color of the text.

### Returns

`ChartText` — ChartText.

### Examples

C#:

```csharp
var index = Bars.Count - 1;
var text = Chart.DrawText("lowLabel", "Low", index, Bars.LowPrices[index], Color.Orange);
text.VerticalAlignment = VerticalAlignment.Top;
Print("Text drawn at {0}", text.Time);
```

Python:

```python
index = api.Bars.Count - 1
text = api.Chart.DrawText("lowLabel", "Low", index, api.Bars.LowPrices[index], Color.Orange)
text.VerticalAlignment = VerticalAlignment.Top
api.Print(f"Text drawn at {text.Time}")
```

