Appearance
line
How do you draw a line from one bar to another? Call line.new with two bars and two prices, or two chart.points, and keep the handle to move it later. A line drawn from the last pivot to the next one is the usual case: make it when the pivot comes, then move its second end on each bar.
pine
//@version=6
indicator("Since the last high", overlay = true)
var line ray = na
ph = ta.pivothigh(high, 5, 5)
if not na(ph)
// A new pivot: a new line from it, which the bars after it move.
ray := line.new(bar_index - 5, ph, bar_index, close, color = color.orange)
line.set_xy2(ray, bar_index, close)A deleted line leaves the chart and line.all at once, and so does any linefill on it. Its getters read na and its setters do nothing. Past max_lines_count + 5 lines on the chart, the oldest go until max_lines_count are left, 50 by default, as with labels. A drawing placed at a bar before the one that made it, such as bar_index - 5, runs with a leak warning: on the chart it looks known earlier than it was.
line.new
pine
line.new(x1, y1, x2, y2, xloc, extend, color, style, width, force_overlay) → series line
line.new(x1, y1, x2, y2, xloc, extend, color, style, width, force_overlay, first_point, second_point) → series lineMakes a line between two points, and returns its handle.
In the second form, two chart.points stand in for the four coordinates. Left out there, xloc follows the first point: one made by chart.point.from_time places by time, any other by bar index.
| Parameter | Default | Description |
|---|---|---|
x1series int | The first end's bar, as a bar index, or a time in milliseconds under xloc.bar_time. | |
y1series int/float | The first end's price. | |
x2series int | The second end's bar. | |
y2series int/float | The second end's price. | |
xlocseries string | xloc.bar_index | Whether the x values are bar indexes or times. |
extendseries string | extend.none | extend.left, extend.right or extend.both carry the line on past its ends to the chart's edge. |
colorseries color | color.blue | The line's colour. |
styleseries string | line.style_solid | See line.style_*. |
widthseries int | 1 | The width in pixels. |
force_overlayconst bool | false | true draws on the price pane even from a script with a pane of its own. |
first_pointchart.point | A chart.point for the first end. | |
second_pointchart.point | A chart.point for the second end. |
line.copy
pine
line.copy(id) → series lineAlso a method: id.copy().
A new line with every value of id. A deleted line copies too, and the copy is on the chart.
| Parameter | Description |
|---|---|
idseries line | The line to copy. |
line.delete
pine
line.delete(id) → voidAlso a method: id.delete().
Takes the line off the chart and out of line.all, with any linefill on it.
| Parameter | Description |
|---|---|
idseries line | The line. |
line.all
pine
array<line> line.allAn array of every line the script has on the chart, oldest first. A deleted line, or one the count took, isn't in it.
line.get_x1
pine
line.get_x1(id) → series intAlso a method: id.get_x1().
The first end's bar index, or its time under xloc.bar_time.
| Parameter | Description |
|---|---|
idseries line | The line. |
line.get_x2
pine
line.get_x2(id) → series intAlso a method: id.get_x2().
The second end's bar index, or its time under xloc.bar_time.
| Parameter | Description |
|---|---|
idseries line | The line. |
line.get_y1
pine
line.get_y1(id) → series floatAlso a method: id.get_y1().
The first end's price.
| Parameter | Description |
|---|---|
idseries line | The line. |
line.get_y2
pine
line.get_y2(id) → series floatAlso a method: id.get_y2().
The second end's price.
| Parameter | Description |
|---|---|
idseries line | The line. |
line.get_price
pine
line.get_price(id, x) → series floatAlso a method: id.get_price(x).
The line's price at bar index x.
It reads the straight line through both ends, so an x past either end gives the price the line would reach there, whatever its extend. A line whose ends share a bar reads y1.
| Parameter | Description |
|---|---|
idseries line | The line. |
xseries int | The bar index. |
line.set_x1
pine
line.set_x1(id, x) → voidAlso a method: id.set_x1(x).
Moves the first end to another bar.
| Parameter | Description |
|---|---|
idseries line | The line. |
xseries int | The bar index, or the time under xloc.bar_time. |
line.set_x2
pine
line.set_x2(id, x) → voidAlso a method: id.set_x2(x).
Moves the second end to another bar.
| Parameter | Description |
|---|---|
idseries line | The line. |
xseries int | The bar index, or the time under xloc.bar_time. |
line.set_y1
pine
line.set_y1(id, y) → voidAlso a method: id.set_y1(y).
Moves the first end to another price.
| Parameter | Description |
|---|---|
idseries line | The line. |
yseries int/float | The price. |
line.set_y2
pine
line.set_y2(id, y) → voidAlso a method: id.set_y2(y).
Moves the second end to another price.
| Parameter | Description |
|---|---|
idseries line | The line. |
yseries int/float | The price. |
line.set_xy1
pine
line.set_xy1(id, x, y) → voidAlso a method: id.set_xy1(x, y).
Moves the first end to another bar and price.
| Parameter | Description |
|---|---|
idseries line | The line. |
xseries int | The bar index, or the time under xloc.bar_time. |
yseries int/float | The price. |
line.set_xy2
pine
line.set_xy2(id, x, y) → voidAlso a method: id.set_xy2(x, y).
Moves the second end to another bar and price.
| Parameter | Description |
|---|---|
idseries line | The line. |
xseries int | The bar index, or the time under xloc.bar_time. |
yseries int/float | The price. |
line.set_first_point
pine
line.set_first_point(id, point) → voidAlso a method: id.set_first_point(point).
Moves the first end to a point, read by the line's own xloc.
| Parameter | Description |
|---|---|
idseries line | The line. |
pointchart.point | The chart.point. |
line.set_second_point
pine
line.set_second_point(id, point) → voidAlso a method: id.set_second_point(point).
Moves the second end to a point, read by the line's own xloc.
| Parameter | Description |
|---|---|
idseries line | The line. |
pointchart.point | The chart.point. |
line.set_xloc
pine
line.set_xloc(id, x1, x2, xloc) → voidAlso a method: id.set_xloc(x1, x2, xloc).
Sets both ends' bars and whether they're bar indexes or times, together.
| Parameter | Description |
|---|---|
idseries line | The line. |
x1series int | The first end's bar index or time. |
x2series int | The second end's bar index or time. |
xlocseries string | xloc.bar_index or xloc.bar_time. |
line.set_extend
pine
line.set_extend(id, extend) → voidAlso a method: id.set_extend(extend).
Sets whether the line carries on past its ends.
| Parameter | Description |
|---|---|
idseries line | The line. |
extendseries string | extend.none, extend.left, extend.right or extend.both. |
line.set_color
pine
line.set_color(id, color) → voidAlso a method: id.set_color(color).
Sets the line's colour.
| Parameter | Description |
|---|---|
idseries line | The line. |
colorseries color | The colour. |
line.set_style
pine
line.set_style(id, style) → voidAlso a method: id.set_style(style).
Sets the line's style.
| Parameter | Description |
|---|---|
idseries line | The line. |
styleseries string | A line.style_* value. |
line.set_width
pine
line.set_width(id, width) → voidAlso a method: id.set_width(width).
Sets the line's width.
| Parameter | Description |
|---|---|
idseries line | The line. |
widthseries int | The width in pixels. |
line.style_*
Values for a line's style.
Each is a const string.
| Name | What it means |
|---|---|
line. | A solid line with an arrowhead at each end. |
line. | A solid line with an arrowhead at the first end. |
line. | A solid line with an arrowhead at the second end. |
line. | A dashed line. |
line. | A dotted line. |
line. | An unbroken line. |