extendedLine

Draw a line that goes through two chosen points and extends infinitely in both directions. This is handy when you want to see a complete trend extension that keeps going left and right, rather than stopping at your selected candles.

Syntax

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

Parameters

  • fromPoint: First anchor point on the chart. Use newPoint(time, price).

  • toPoint: Second anchor point. The line will pass through this point too.

  • styles (optional) Control how the line looks:

    • linecolor: color of the line (e.g. color.red)

    • linewidth: thickness of the line

    • linestyle: solid, dashed, dotted, etc.

    • showLabel: show or hide the label

    • textcolor: label text color

  • text (optional): A short label to display on the line (if showLabel: true).

Return Value

  • string — A unique id for the drawing. Use it with updateDrawingById(id, data) or deleteDrawingById(id).

Example

Here’s how to draw a red extended line through the highs of the last 5 and last 0 candles:

This will draw one red line passing through the two highs and continuing both left and right across the chart, with a small label “Extended Line.”

Result

Tips

  • Extended lines are great for projecting old support/resistance across the entire chart.

  • Use them sparingly so your chart doesn’t become full of crossing lines.

Warning

Good Practice

Last updated