Skip to content

line

Properties

all

Type: series array<line>

Returns an array filled with all the current lines drawn by the script.


style_arrow_both

Type: const string

Line style for line.new() and line.set_style() functions.


style_arrow_left

Type: const string

Line style for line.new() and line.set_style() functions.


style_arrow_right

Type: const string

Line style for line.new() and line.set_style() functions.


style_dashed

Type: const string

Line style for line.new() and line.set_style() functions.


style_dotted

Type: const string

Line style for line.new() and line.set_style() functions.


style_solid

Type: const string

Line style for line.new() and line.set_style() functions.

Functions

new

Creates a line object on the chart.

Parameters

NameTypeDefaultDescription
first_pointseries chart.pointThe chart.point object specifying the first point of the line.
second_pointseries chart.pointThe chart.point object specifying the second point of the line.
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
extendseries stringextend.noneThe extension mode: extend.none, extend.left, extend.right, or extend.both.
colorseries colornaThe color of the line.
styleseries stringstyle_solidThe line style.
widthseries int1The line width in pixels.
force_overlayseries boolfalseIf true, the line is rendered on top.

Returns: series line

Creates a line object on the chart.

Parameters

NameTypeDefaultDescription
x1series intThe x-coordinate of the first point (bar index or UNIX time).
y1series floatThe y-coordinate of the first point (price).
x2series intThe x-coordinate of the second point (bar index or UNIX time).
y2series floatThe y-coordinate of the second point (price).
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
extendseries stringextend.noneThe extension mode: extend.none, extend.left, extend.right, or extend.both.
colorseries colornaThe color of the line.
styleseries stringstyle_solidThe line style.
widthseries int1The line width in pixels.
force_overlayseries boolfalseIf true, the line is rendered on top.

Returns: series line

Methods

copy

pine
line.copy(series line id) → series line

Creates a copy of the specified line and returns its id.

Parameters

NameTypeDefaultDescription
idseries lineThe line to copy.

Returns: series line


delete

pine
line.delete(series line id)

Deletes the specified line from the chart.

Parameters

NameTypeDefaultDescription
idseries lineThe line to delete.

get_price

pine
line.get_price(series line id, series int x) → series float

Returns the price level of a line at a given bar index.

Parameters

NameTypeDefaultDescription
idseries lineThe line to get the price from.
xseries intThe bar index or UNIX time to get the price at.

Returns: series float


get_x1

pine
line.get_x1(series line id) → series int

Returns UNIX time or bar index (depending on the last xloc value set) of the first point of the line.

Parameters

NameTypeDefaultDescription
idseries lineThe line to get the x1 coordinate from.

Returns: series int


get_x2

pine
line.get_x2(series line id) → series int

Returns UNIX time or bar index (depending on the last xloc value set) of the second point of the line.

Parameters

NameTypeDefaultDescription
idseries lineThe line to get the x2 coordinate from.

Returns: series int


get_y1

pine
line.get_y1(series line id) → series float

Returns price of the first point of the line.

Parameters

NameTypeDefaultDescription
idseries lineThe line to get the y1 coordinate from.

Returns: series float


get_y2

pine
line.get_y2(series line id) → series float

Returns price of the second point of the line.

Parameters

NameTypeDefaultDescription
idseries lineThe line to get the y2 coordinate from.

Returns: series float


set_color

pine
line.set_color(series line id, series color color)

Sets the line color.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
colorseries colorThe new color of the line.

set_extend

pine
line.set_extend(series line id, series string extend)

Sets extending type of this line object.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
extendseries stringThe extension mode: extend.none, extend.left, extend.right, or extend.both.

set_first_point

pine
line.set_first_point(series line id, series chart.point point)

Sets the first point of this line object.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
pointseries chart.pointThe chart.point object specifying the new first point.

set_second_point

pine
line.set_second_point(series line id, series chart.point point)

Sets the second point of this line object.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
pointseries chart.pointThe chart.point object specifying the new second point.

set_style

pine
line.set_style(series line id, series string style)

Sets the line style.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
styleseries stringThe new line style.

set_width

pine
line.set_width(series line id, series int width)

Sets the line width.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
widthseries intThe new line width in pixels.

set_x1

pine
line.set_x1(series line id, series int x)

Sets bar index or bar time (depending on the xloc) of the first point.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
xseries intThe new x-coordinate for the first point.

set_x2

pine
line.set_x2(series line id, series int x)

Sets bar index or bar time (depending on the xloc) of the second point.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
xseries intThe new x-coordinate for the second point.

set_xloc

pine
line.set_xloc(series line id, series int x1, series int x2, series string xloc)

Sets x-location and new bar index/time values.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
x1series intThe new x-coordinate for the first point.
x2series intThe new x-coordinate for the second point.
xlocseries stringThe x-location type: xloc.bar_index or xloc.bar_time.

set_xy1

pine
line.set_xy1(series line id, series int x, series float y)

Sets bar index/time and price of the first point.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
xseries intThe new x-coordinate for the first point.
yseries floatThe new y-coordinate for the first point.

set_xy2

pine
line.set_xy2(series line id, series int x, series float y)

Sets bar index/time and price of the second point.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
xseries intThe new x-coordinate for the second point.
yseries floatThe new y-coordinate for the second point.

set_y1

pine
line.set_y1(series line id, series float y)

Sets price of the first point.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
yseries floatThe new y-coordinate for the first point.

set_y2

pine
line.set_y2(series line id, series float y)

Sets price of the second point.

Parameters

NameTypeDefaultDescription
idseries lineThe line to modify.
yseries floatThe new y-coordinate for the second point.

Released under the MIT License.