Line
Handle for a line drawing.
Static Methods
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 Xloc | Xloc.BarIndex | The x-location type: Xloc.BarIndex or Xloc.BarTime. |
extend | series Extend | 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 LineStyle | LineStyle.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
Static Properties
all
Returns an array filled with all the current lines drawn by the script.
Methods
copy
Line.copy(id: series Line): 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(id: series Line)Deletes the specified line from the chart.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series Line | The line to delete. |
get_price
Line.get_price(id: series Line, x: series int): 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(id: series Line): 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(id: series Line): 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(id: series Line): 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(id: series Line): 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(id: series Line, color: series 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(id: series Line, extend: series Extend)Sets extending type of this line object.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series Line | The line to modify. | |
extend | series Extend | The extension mode: Extend.None, Extend.Left, Extend.Right, or Extend.Both. |
set_first_point
Line.set_first_point(id: series Line, point: series chart.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(id: series Line, point: series chart.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(id: series Line, style: series LineStyle)Sets the line style.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series Line | The line to modify. | |
style | series LineStyle | The new line style. |
set_width
Line.set_width(id: series Line, width: series int)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(id: series Line, x: series int)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(id: series Line, x: series int)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(
id: series Line,
x1: series int,
x2: series int,
xloc: series 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 Xloc | The x-location type: Xloc.BarIndex or Xloc.BarTime. |
set_xy1
Line.set_xy1(id: series Line, x: series int, y: series float)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(id: series Line, x: series int, y: series float)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(id: series Line, y: series float)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(id: series Line, y: series float)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. |