infoLine

Draw a line between two points that also shows extra information, like the price difference, percentage change, or even a custom label. Think of it as a measuring tool that’s always attached to the chart.

Syntax

infoLine(fromPoint, toPoint, styles?, text?)

Parameters

  • fromPoint: Starting point of the line. Use newPoint(time, price).

  • toPoint: End point of the line. Also built with newPoint(time, price).

  • styles (optional) Options to style the info line:

    • linecolor: line color (e.g. color.green)

    • linewidth: line thickness

    • linestyle: line type (solid, dashed, etc.)

    • showLabel: show the info box/label (true/false)

    • textcolor: color of the label text

    • extendRight / extendLeft: extend the line beyond the chosen points

  • text (optional): A short custom label you want to show on the line.

Return Value

  • string — A unique drawing id you can later use to update or delete the line.

Example

Draw one info line between the last two candle closes, showing the label “Measure”:

You’ll see one green info line connecting the last two closing prices, with a small label showing “Measure.”

Result

Tips

  • Tip: Use infoLine when you want to highlight movement between two points (like high vs. low, or yesterday vs. today).

  • Tip: If you add showLabel: true without custom text, it still shows useful info (like % change).

Warning

  • Warning: If you forget to provide both fromPoint and toPoint, nothing will be drawn.

  • Warning: Passing a label in text without showLabel: true means the label won’t appear.

Good Practice

  • Good Practice: Keep your info lines temporary (like measuring tools), so don’t clutter the chart with many of them.

  • Good Practice: Pick neutral colors (gray/blue) for measuring lines so they don’t distract from your main signals.

Last updated