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: thickness of the line

    • linestyle: 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.

Result

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.

Warning

Good Practice

Last updated