# verticalLine

A vertical line is a simple tool that lets you mark a specific **time (candle)** on the chart. Traders often use it to highlight important events, such as news releases, earnings, or just to separate sessions/days.

### Syntax

`verticalLine(time, styles?, text?)`

### Parameters

* **time:** The candle time where the vertical line should be drawn (for example, `time(20)` means 20 candles ago).
* **styles** (optional)\
  Style options for how the line looks:
  * `linecolor`: color of the line (e.g., `color.blue`)
  * [`linewidth`](/custom-indicators-docs/charting-library/linewidth.md): thickness of the line
  * [`linestyle`](/custom-indicators-docs/charting-library/linestyle.md): solid, dashed, or dotted
  * `showLabel`: show a label on the line (true/false)
  * `textcolor`: the color of the label text
* **text** (optional): A short label to display on the line (if `showLabel: true`).

### Return Value

* **string** — A unique drawing `id`.

### Example

This example will draw a blue vertical line every 30 candles to mark sections on the chart. We also add a label “Marker” so it’s clear what the line represents.

```js
//@version=1
init = () => {
    // Put this indicator on the main price chart
    indicator({ onMainPanel: true, format: 'inherit' });
};

onTick = () => {
    // Every 30 candles, draw a new vertical line
    if (index % 30 === 0) {
        // Choose the current candle time as the marker
        const time_line = time(0);

        // Draw the vertical line
        // - Starts at the current time (t)
        // - Styled in blue
        // - Thickness set to 2
        // - showLabel = true, so the text appears
        // - Label set as "Marker"
        verticalLine(
            time_line ,
            { linecolor: color.blue, linewidth: 2, showLabel: true },
            'Marker'
        );
    }
};
```

### Result

<figure><img src="/files/VZGSyY7k0SbfJovDv6RG" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}

### Tips

* Use vertical lines to highlight recurring patterns (like market opens or closes).
* Dashed vertical lines are useful for visual guides without overwhelming the chart.
  {% endhint %}

{% hint style="danger" %}

### Warning

* If `time` is invalid or outside the chart, the line won’t appear.
* Adding too many vertical lines too often can clutter the chart and make it hard to read.
  {% endhint %}

{% hint style="success" %}

### Good Practice

* Use vertical lines as “markers,” not as permanent drawings. For example, to mark events or \
  analysis points.
* Keep labels short (like “News” or “Open”) so the chart stays clean and readable.
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://custom-indicators.gitbook.io/custom-indicators-docs/chart-drawing-tools/lines-and-rays/verticalline.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
