line
Lines between two points.
#Functions
#line.copyfunction
A new line with the same properties.
line.copy(id: line): line| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
Returns line.
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
const l2 = ln.copy()Since ChartScript 1
#line.deletefunction
Removes the line.
line.delete(id: line)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.delete()Since ChartScript 1
#line.get_pricefunction
The price of the line at a bar index (extended as a straight line).
line.get_price(id: line, x: int): float| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
x | int | The value. |
Returns float.
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
const v = ln.get_price(bar_index)Since ChartScript 1
#line.get_x1function
The bar of a point (index or time).
line.get_x1(id: line): int| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
Returns int.
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
const v = ln.get_x1()Since ChartScript 1
#line.get_x2function
The bar of a point (index or time).
line.get_x2(id: line): int| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
Returns int.
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
const v = ln.get_x2()Since ChartScript 1
#line.get_y1function
The price of a point.
line.get_y1(id: line): float| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
Returns float.
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
const v = ln.get_y1()Since ChartScript 1
#line.get_y2function
The price of a point.
line.get_y2(id: line): float| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
Returns float.
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
const v = ln.get_y2()Since ChartScript 1
#line.newfunction
A line from (x1, y1) to (x2, y2). The oldest is removed past max_lines_count.
line.new(x1: int, y1: float, x2: int, y2: float, { xloc?: simple string = xloc.bar_index, extend?: string = extend.none, color?: color = color.blue, style?: string = line.style_solid, width?: int = 1, force_overlay?: const bool = false, look?: const string = "" }): lineline.new(first_point: point, second_point: point, { xloc?: simple string = xloc.bar_index, extend?: string = extend.none, color?: color = color.blue, style?: string = line.style_solid, width?: int = 1, force_overlay?: const bool = false, look?: const string = "" }): line| Parameter | Type | Description |
|---|---|---|
x1 | int | The x1. |
y1 | float | The y1. |
x2 | int | The x2. |
y2 | float | The y2. |
xloc | simple stringdefault xloc.bar_index | The xloc. |
extend | stringdefault extend.none | The extend. |
color | colordefault color.blue | The colour. |
style | stringdefault line.style_solid | The style constant. |
width | intdefault 1 | The width. |
force_overlay | const booldefault false | Accepted and ignored in this version. |
look | const stringdefault "" | The look. |
first_point | point | The first point. |
second_point | point | The second point. |
Returns line.
Example
const ln = line.new(bar_index - 10, low, bar_index, high)Since ChartScript 1
#line.set_colorfunction
Sets the colour.
line.set_color(id: line, color: color)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
color | color | The colour. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_color(color.red)Since ChartScript 1
#line.set_extendfunction
Extends the line (extend.*).
line.set_extend(id: line, extend: string)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
extend | string | The extend. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_extend(extend.right)Since ChartScript 1
#line.set_first_pointfunction
Sets the first point from a chart.point.
line.set_first_point(id: line, point: point)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
point | point | The point. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_first_point(chart.point.now(low))Since ChartScript 1
#line.set_second_pointfunction
Sets the second point from a chart.point.
line.set_second_point(id: line, point: point)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
point | point | The point. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_second_point(chart.point.now(high))Since ChartScript 1
#line.set_stylefunction
Sets the dash or arrow style (line.style_*).
line.set_style(id: line, style: string)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
style | string | The style constant. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_style(line.style_dashed)Since ChartScript 1
#line.set_widthfunction
Sets the width in pixels.
line.set_width(id: line, width: int)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
width | int | The width. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_width(2)Since ChartScript 1
#line.set_x1function
Sets the first bar.
line.set_x1(id: line, x: int)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
x | int | The value. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_x1(bar_index)Since ChartScript 1
#line.set_x2function
Sets the second bar.
line.set_x2(id: line, x: int)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
x | int | The value. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_x2(bar_index)Since ChartScript 1
#line.set_xlocfunction
Sets both bars and how they are read.
line.set_xloc(id: line, x1: int, x2: int, xloc: string)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
x1 | int | The x1. |
x2 | int | The x2. |
xloc | string | The xloc. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_xloc(time, time, xloc.bar_time)Since ChartScript 1
#line.set_xy1function
Sets the first point.
line.set_xy1(id: line, x: int, y: float)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
x | int | The value. |
y | float | The y. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_xy1(bar_index, low)Since ChartScript 1
#line.set_xy2function
Sets the second point.
line.set_xy2(id: line, x: int, y: float)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
x | int | The value. |
y | float | The y. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_xy2(bar_index, high)Since ChartScript 1
#line.set_y1function
Sets the first price.
line.set_y1(id: line, y: float)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
y | float | The y. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_y1(low)Since ChartScript 1
#line.set_y2function
Sets the second price.
line.set_y2(id: line, y: float)| Parameter | Type | Description |
|---|---|---|
id | line | The array. |
y | float | The y. |
Example
const ln = line.new(bar_index - 1, low, bar_index, high)
ln.set_y2(high)Since ChartScript 1
#Variables
#line.allvariable
Every line of the script that still exists, oldest first.
line.all: array<line>Type series array<line>.
Example
const n = array.size(line.all)Since ChartScript 1
#Constants
| Name | Type | Description |
|---|---|---|
line.style_arrow_both | string | Line dash / arrow style. |
line.style_arrow_left | string | Line dash / arrow style. |
line.style_arrow_right | string | Line dash / arrow style. |
line.style_dashed | string | Line dash / arrow style. |
line.style_dotted | string | Line dash / arrow style. |
line.style_solid | string | Line dash / arrow style. |