Skip to content

Line

Handle for a line drawing.

Static Methods

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 XlocXloc.BarIndexThe x-location type: Xloc.BarIndex or Xloc.BarTime.
extendseries ExtendExtend.NoneThe extension mode: Extend.None, Extend.Left, Extend.Right, or Extend.Both.
colorseries colornaThe color of the line.
styleseries LineStyleLineStyle.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 XlocXloc.BarIndexThe x-location type: Xloc.BarIndex or Xloc.BarTime.
extendseries ExtendExtend.NoneThe extension mode: Extend.None, Extend.Left, Extend.Right, or Extend.Both.
colorseries colornaThe color of the line.
styleseries LineStyleLineStyle.SolidThe line style.
widthseries int1The line width in pixels.
force_overlayseries boolfalseIf true, the line is rendered on top.

Returns: series Line

Static Properties

all

Type: series Array<Line>

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

Methods

copy

navi
Line.copy(id: series Line): series Line

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

Parameters

NameTypeDefaultDescription
idseries LineThe line to copy.

Returns: series Line


delete

navi
Line.delete(id: series Line)

Deletes the specified line from the chart.

Parameters

NameTypeDefaultDescription
idseries LineThe line to delete.

get_price

navi
Line.get_price(id: series Line, x: series int): 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

navi
Line.get_x1(id: series Line): 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

navi
Line.get_x2(id: series Line): 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

navi
Line.get_y1(id: series Line): 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

navi
Line.get_y2(id: series Line): 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

navi
Line.set_color(id: series Line, color: series color)

Sets the line color.

Parameters

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

set_extend

navi
Line.set_extend(id: series Line, extend: series Extend)

Sets extending type of this line object.

Parameters

NameTypeDefaultDescription
idseries LineThe line to modify.
extendseries ExtendThe extension mode: Extend.None, Extend.Left, Extend.Right, or Extend.Both.

set_first_point

navi
Line.set_first_point(id: series Line, point: series chart.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

navi
Line.set_second_point(id: series Line, point: series chart.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

navi
Line.set_style(id: series Line, style: series LineStyle)

Sets the line style.

Parameters

NameTypeDefaultDescription
idseries LineThe line to modify.
styleseries LineStyleThe new line style.

set_width

navi
Line.set_width(id: series Line, width: series int)

Sets the line width.

Parameters

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

set_x1

navi
Line.set_x1(id: series Line, x: series int)

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

navi
Line.set_x2(id: series Line, x: series int)

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

navi
Line.set_xloc(
    id: series Line,
    x1: series int,
    x2: series int,
    xloc: series 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 XlocThe x-location type: Xloc.BarIndex or Xloc.BarTime.

set_xy1

navi
Line.set_xy1(id: series Line, x: series int, y: series float)

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

navi
Line.set_xy2(id: series Line, x: series int, y: series float)

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

navi
Line.set_y1(id: series Line, y: series float)

Sets price of the first point.

Parameters

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

set_y2

navi
Line.set_y2(id: series Line, y: series float)

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.