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
| Name | Type | Default | Description |
|---|---|---|---|
first_point | series chart.point | The chart.point object specifying the first point of the line. | |
second_point | series chart.point | The chart.point object specifying the second point of the line. | |
xloc | series string | xloc.bar_index | The x-location type: xloc.bar_index or xloc.bar_time. |
extend | series string | extend.none | The extension mode: extend.none, extend.left, extend.right, or extend.both. |
color | series color | na | The color of the line. |
style | series string | style_solid | The line style. |
width | series int | 1 | The line width in pixels. |
force_overlay | series bool | false | If true, the line is rendered on top. |
Returns: series line
Methods
copy
line.copy(series line id) → series lineCreates a copy of the specified line and returns its id.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to copy. |
Returns: series line
delete
line.delete(series line id)Deletes the specified line from the chart.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to delete. |
get_price
line.get_price(series line id, series int x) → series floatReturns the price level of a line at a given bar index.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to get the price from. | |
x | series int | The bar index or UNIX time to get the price at. |
Returns: series float
get_x1
line.get_x1(series line id) → series intReturns UNIX time or bar index (depending on the last xloc value set) of the first point of the line.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to get the x1 coordinate from. |
Returns: series int
get_x2
line.get_x2(series line id) → series intReturns UNIX time or bar index (depending on the last xloc value set) of the second point of the line.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to get the x2 coordinate from. |
Returns: series int
get_y1
line.get_y1(series line id) → series floatReturns price of the first point of the line.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to get the y1 coordinate from. |
Returns: series float
get_y2
line.get_y2(series line id) → series floatReturns price of the second point of the line.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to get the y2 coordinate from. |
Returns: series float
set_color
line.set_color(series line id, series color color)Sets the line color.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
color | series color | The new color of the line. |
set_extend
line.set_extend(series line id, series string extend)Sets extending type of this line object.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
extend | series string | The extension mode: extend.none, extend.left, extend.right, or extend.both. |
set_first_point
line.set_first_point(series line id, series chart.point point)Sets the first point of this line object.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
point | series chart.point | The chart.point object specifying the new first point. |
set_second_point
line.set_second_point(series line id, series chart.point point)Sets the second point of this line object.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
point | series chart.point | The chart.point object specifying the new second point. |
set_style
line.set_style(series line id, series string style)Sets the line style.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
style | series string | The new line style. |
set_width
line.set_width(series line id, series int width)Sets the line width.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
width | series int | The new line width in pixels. |
set_x1
line.set_x1(series line id, series int x)Sets bar index or bar time (depending on the xloc) of the first point.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
x | series int | The new x-coordinate for the first point. |
set_x2
line.set_x2(series line id, series int x)Sets bar index or bar time (depending on the xloc) of the second point.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
x | series int | The new x-coordinate for the second point. |
set_xloc
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
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
x1 | series int | The new x-coordinate for the first point. | |
x2 | series int | The new x-coordinate for the second point. | |
xloc | series string | The x-location type: xloc.bar_index or xloc.bar_time. |
set_xy1
line.set_xy1(series line id, series int x, series float y)Sets bar index/time and price of the first point.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
x | series int | The new x-coordinate for the first point. | |
y | series float | The new y-coordinate for the first point. |
set_xy2
line.set_xy2(series line id, series int x, series float y)Sets bar index/time and price of the second point.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
x | series int | The new x-coordinate for the second point. | |
y | series float | The new y-coordinate for the second point. |
set_y1
line.set_y1(series line id, series float y)Sets price of the first point.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
y | series float | The new y-coordinate for the first point. |
set_y2
line.set_y2(series line id, series float y)Sets price of the second point.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series line | The line to modify. | |
y | series float | The new y-coordinate for the second point. |