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

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

# ChartArea.DrawVerticalLine

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

## DrawVerticalLine(string name, DateTime time, Color color)

Draws a vertical 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
ChartVerticalLine DrawVerticalLine(string name, DateTime time, Color color)
```

Python:

```python
chartArea.DrawVerticalLine(name: str, time: DateTime, color: Color) -> ChartVerticalLine
```

### 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.
- `time` (`DateTime`, Python `DateTime`): The time value on the X-axis.
- `color` (`Color`, Python `Color`): The line color.

### Returns

`ChartVerticalLine` — ChartVerticalLine.

### Examples

C#:

```csharp
var line = Chart.DrawVerticalLine("today", Server.Time.Date, Color.Gray);
Print("Vertical line drawn at {0}", line.Time);
```

Python:

```python
line = api.Chart.DrawVerticalLine("today", api.Server.Time.Date, Color.Gray)
api.Print(f"Vertical line drawn at {line.Time}")
```

## DrawVerticalLine(string name, DateTime time, Color color, int thickness)

Draws a vertical 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
ChartVerticalLine DrawVerticalLine(string name, DateTime time, Color color, int thickness)
```

Python:

```python
chartArea.DrawVerticalLine(name: str, time: DateTime, color: Color, thickness: int) -> ChartVerticalLine
```

### 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.
- `time` (`DateTime`, Python `DateTime`): The time value of the line location on the X-axis.
- `color` (`Color`, Python `Color`): The line color.
- `thickness` (`int`, Python `int`): The line thickness.

### Returns

`ChartVerticalLine` — ChartVerticalLine.

### Examples

C#:

```csharp
var line = Chart.DrawVerticalLine("today", Server.Time.Date, Color.Gray, 2);
Print("Vertical line drawn at {0} with thickness {1}", line.Time, line.Thickness);
```

Python:

```python
line = api.Chart.DrawVerticalLine("today", api.Server.Time.Date, Color.Gray, 2)
api.Print(f"Vertical line drawn at {line.Time} with thickness {line.Thickness}")
```

## DrawVerticalLine(string name, DateTime time, Color color, int thickness, LineStyle lineStyle)

Draws a vertical 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
ChartVerticalLine DrawVerticalLine(string name, DateTime time, Color color, int thickness, LineStyle lineStyle)
```

Python:

```python
chartArea.DrawVerticalLine(name: str, time: DateTime, color: Color, thickness: int, lineStyle: LineStyle) -> ChartVerticalLine
```

### 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.
- `time` (`DateTime`, Python `DateTime`): The time value of the line location on the X-axis.
- `color` (`Color`, Python `Color`): The line color.
- `thickness` (`int`, Python `int`): The line thickness.
- `lineStyle` (`LineStyle`, Python `LineStyle`): The line style.

### Returns

`ChartVerticalLine` — ChartVerticalLine.

### Examples

C#:

```csharp
var line = Chart.DrawVerticalLine("today", Server.Time.Date, Color.Gray, 1, LineStyle.DotsRare);
Print("Vertical line drawn at {0} with style {1}", line.Time, line.LineStyle);
```

Python:

```python
line = api.Chart.DrawVerticalLine("today", api.Server.Time.Date, Color.Gray, 1, LineStyle.DotsRare)
api.Print(f"Vertical line drawn at {line.Time} with style {line.LineStyle}")
```

## DrawVerticalLine(string name, int barIndex, Color color)

Draws a vertical 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
ChartVerticalLine DrawVerticalLine(string name, int barIndex, Color color)
```

Python:

```python
chartArea.DrawVerticalLine(name: str, barIndex: int, color: Color) -> ChartVerticalLine
```

### 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.
- `barIndex` (`int`, Python `int`): The bar index of the line location on the X-axis.
- `color` (`Color`, Python `Color`): The line color.

### Returns

`ChartVerticalLine` — ChartVerticalLine.

### Examples

C#:

```csharp
var line = Chart.DrawVerticalLine("lastBar", Bars.Count - 1, Color.Gray);
Print("Vertical line drawn at {0}", line.Time);
```

Python:

```python
line = api.Chart.DrawVerticalLine("lastBar", api.Bars.Count - 1, Color.Gray)
api.Print(f"Vertical line drawn at {line.Time}")
```

## DrawVerticalLine(string name, int barIndex, Color color, int thickness)

Draws a vertical 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
ChartVerticalLine DrawVerticalLine(string name, int barIndex, Color color, int thickness)
```

Python:

```python
chartArea.DrawVerticalLine(name: str, barIndex: int, color: Color, thickness: int) -> ChartVerticalLine
```

### 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.
- `barIndex` (`int`, Python `int`): The bar index of the line location on the X-axis.
- `color` (`Color`, Python `Color`): The line color.
- `thickness` (`int`, Python `int`): The line thickness.

### Returns

`ChartVerticalLine` — ChartVerticalLine.

### Examples

C#:

```csharp
var line = Chart.DrawVerticalLine("lastBar", Bars.Count - 1, Color.Gray, 2);
Print("Vertical line drawn at {0} with thickness {1}", line.Time, line.Thickness);
```

Python:

```python
line = api.Chart.DrawVerticalLine("lastBar", api.Bars.Count - 1, Color.Gray, 2)
api.Print(f"Vertical line drawn at {line.Time} with thickness {line.Thickness}")
```

## DrawVerticalLine(string name, int barIndex, Color color, int thickness, LineStyle lineStyle)

Draws a vertical 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
ChartVerticalLine DrawVerticalLine(string name, int barIndex, Color color, int thickness, LineStyle lineStyle)
```

Python:

```python
chartArea.DrawVerticalLine(name: str, barIndex: int, color: Color, thickness: int, lineStyle: LineStyle) -> ChartVerticalLine
```

### 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.
- `barIndex` (`int`, Python `int`): The bar index of the line location on the X-axis.
- `color` (`Color`, Python `Color`): The line color.
- `thickness` (`int`, Python `int`): The line thickness.
- `lineStyle` (`LineStyle`, Python `LineStyle`): The line style.

### Returns

`ChartVerticalLine` — 

### Examples

C#:

```csharp
var line = Chart.DrawVerticalLine("lastBar", Bars.Count - 1, Color.Gray, 1, LineStyle.Dots);
Print("Vertical line drawn at {0} with style {1}", line.Time, line.LineStyle);
```

Python:

```python
line = api.Chart.DrawVerticalLine("lastBar", api.Bars.Count - 1, Color.Gray, 1, LineStyle.Dots)
api.Print(f"Vertical line drawn at {line.Time} with style {line.LineStyle}")
```

