Skip to main content
Language version: 2 · Reference version: 2.7 · Date: 2026-10-25 · Compiler build: df7b3b14 · Namespace: line · Entries: 25

line (library)

Definition Functions for creating and mutating line drawings between two chart points. Notes
  • A line.<name>(ln, ...) function can also be called on the line as ln.<name>(...), for example ln.set_x2(bar_index). The one exception is the four-argument form of line.set_xloc, which is a function only (see that entry).
Example

line.all (function)

Definition Returns the array of all existing line objects (same as line.all). Syntax
Returns series array<line> An array of line IDs, oldest to newest. Example

line.copy (function)

Definition Creates a copy of a line. Syntax
Parameters Returns series line The new line ID. Example

line.delete (function)

Definition Deletes a line. Any linefill that uses this line is also deleted. Syntax
Parameters Returns void void Example

line.get_price (function)

Definition Returns the price of a line at x (interpolated between the two endpoints). Syntax
Parameters Returns series float Price at x. Example

line.get_x1 (function)

Definition Returns the first point’s x-coordinate. Syntax
Parameters Returns series int X-coordinate of the first point. Example

line.get_x2 (function)

Definition Returns the second point’s x-coordinate. Syntax
Parameters Returns series int X-coordinate of the second point. Example

line.get_y1 (function)

Definition Returns the first point’s y-coordinate. Syntax
Parameters Returns series float Y-coordinate of the first point. Example

line.get_y2 (function)

Definition Returns the second point’s y-coordinate. Syntax
Parameters Returns series float Y-coordinate of the second point. Example

line.new (function, overload 1)

Definition Creates a line between two points. Coordinates can be passed as x1/y1/x2/y2 or as chartPoint first_point/second_point. Syntax
Parameters Returns series line The ID of the created line. Example

line.new (function, overload 2)

Definition Creates a line between two points. Coordinates can be passed as x1/y1/x2/y2 or as chartPoint first_point/second_point. Syntax
Parameters Returns series line The ID of the created line. Example

line.set_color (function)

Definition Sets a line’s color. Syntax
Parameters Returns void void Example

line.set_extend (function)

Definition Sets whether a line extends past its endpoints. Syntax
Parameters Returns void void Example

line.set_point1 (function)

Definition Sets a line’s first endpoint from a chartPoint. X is taken from the point’s index or time depending on the line’s xloc. Syntax
Parameters Returns void void Example

line.set_point2 (function)

Definition Sets a line’s second endpoint from a chartPoint. X is taken from the point’s index or time depending on the line’s xloc. Syntax
Parameters Returns void void Example

line.set_style (function)

Definition Sets a line’s style (line.style_*). Syntax
Parameters Returns void void Example

line.set_width (function)

Definition Sets a line’s width in pixels. Syntax
Parameters Returns void void Example

line.set_x1 (function)

Definition Sets a line’s first x-coordinate. Syntax
Parameters Returns void void Example

line.set_x2 (function)

Definition Sets a line’s second x-coordinate. Syntax
Parameters Returns void void Example

line.set_xloc (function, overload 1)

Definition Sets whether a line’s x-coordinates are bar indexes or times. Syntax
Parameters Returns void void Example

line.set_xloc (function, overload 2)

Definition Sets whether a line’s x-coordinates are bar indexes or times. Syntax
Parameters Returns void void Notes
  • Function form only: ln.set_xloc(xloc.bar_time, x1, x2) is rejected with “Too many arguments passed into the line.set_xloc() function call. Passed 4 arguments but expected 2.” The two-argument form also works as ln.set_xloc(xloc.bar_index).
Example

line.set_xy1 (function)

Definition Sets a line’s first endpoint (x1, y1). Syntax
Parameters Returns void void Example

line.set_xy2 (function)

Definition Sets a line’s second endpoint (x2, y2). Syntax
Parameters Returns void void Example

line.set_y1 (function)

Definition Sets a line’s first y-coordinate. Syntax
Parameters Returns void void Example

line.set_y2 (function)

Definition Sets a line’s second y-coordinate. Syntax
Parameters Returns void void Example