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

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

# ChartArea.DrawHorizontalLine

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

## DrawHorizontalLine(string name, double y, Color color)

Draws a horizontal line.

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
ChartHorizontalLine DrawHorizontalLine(string name, double y, Color color)
```

Python:

```python
chartArea.DrawHorizontalLine(name: str, y: float, color: Color) -> ChartHorizontalLine
```

### Parameters

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

### Returns

`ChartHorizontalLine` — ChartHorizontalLine.

### Examples

C#:

```csharp
var line = Chart.DrawHorizontalLine("support", Bars.LowPrices.Minimum(50), Color.Green);
Print("Support line drawn at {0}", line.Y);
```

Python:

```python
line = api.Chart.DrawHorizontalLine("support", Functions.Minimum(api.Bars.LowPrices, 50), Color.Green)
api.Print(f"Support line drawn at {line.Y}")
```

## DrawHorizontalLine(string name, double y, Color color, int thickness)

Draws a horizontal line.

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
ChartHorizontalLine DrawHorizontalLine(string name, double y, Color color, int thickness)
```

Python:

```python
chartArea.DrawHorizontalLine(name: str, y: float, color: Color, thickness: int) -> ChartHorizontalLine
```

### 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.
- `y` (`double`, Python `float`): The Y-axis value of the line location.
- `color` (`Color`, Python `Color`): The line color.
- `thickness` (`int`, Python `int`): The line thickness.

### Returns

`ChartHorizontalLine` — ChartHorizontalLine.

### Examples

C#:

```csharp
var line = Chart.DrawHorizontalLine("resistance", Bars.HighPrices.Maximum(50), Color.Red, 2);
Print("Resistance line drawn at {0} with thickness {1}", line.Y, line.Thickness);
```

Python:

```python
line = api.Chart.DrawHorizontalLine("resistance", Functions.Maximum(api.Bars.HighPrices, 50), Color.Red, 2)
api.Print(f"Resistance line drawn at {line.Y} with thickness {line.Thickness}")
```

## DrawHorizontalLine(string name, double y, Color color, int thickness, LineStyle lineStyle)

Draws a horizontal line.

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
ChartHorizontalLine DrawHorizontalLine(string name, double y, Color color, int thickness, LineStyle lineStyle)
```

Python:

```python
chartArea.DrawHorizontalLine(name: str, y: float, color: Color, thickness: int, lineStyle: LineStyle) -> ChartHorizontalLine
```

### 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.
- `y` (`double`, Python `float`): The Y-axis value of the line location.
- `color` (`Color`, Python `Color`): The line color.
- `thickness` (`int`, Python `int`): The line thickness.
- `lineStyle` (`LineStyle`, Python `LineStyle`): The line style.

### Returns

`ChartHorizontalLine` — ChartHorizontalLine.

### Examples

C#:

```csharp
var line = Chart.DrawHorizontalLine("target", Symbol.Bid + 50 * Symbol.PipSize, Color.Gold, 1, LineStyle.Dots);
Print("Target line drawn at {0} with style {1}", line.Y, line.LineStyle);
```

Python:

```python
line = api.Chart.DrawHorizontalLine("target", api.Symbol.Bid + 50 * api.Symbol.PipSize, Color.Gold, 1, LineStyle.Dots)
api.Print(f"Target line drawn at {line.Y} with style {line.LineStyle}")
```

