Skip to content
ChartDeck ChartScript docs Account Open the terminal

line

Lines between two points.

#Functions

#line.copyfunction

A new line with the same properties.

line.copy(id: line): line
ParameterTypeDescription
idlineThe array.

Returns line.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.

Example

ChartScriptFragmentOpen in editor
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
ParameterTypeDescription
idlineThe array.
xintThe value.

Returns float.

Example

ChartScriptFragmentOpen in editor
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
ParameterTypeDescription
idlineThe array.

Returns int.

Example

ChartScriptFragmentOpen in editor
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
ParameterTypeDescription
idlineThe array.

Returns int.

Example

ChartScriptFragmentOpen in editor
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
ParameterTypeDescription
idlineThe array.

Returns float.

Example

ChartScriptFragmentOpen in editor
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
ParameterTypeDescription
idlineThe array.

Returns float.

Example

ChartScriptFragmentOpen in editor
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 = "" }): line
line.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
ParameterTypeDescription
x1intThe x1.
y1floatThe y1.
x2intThe x2.
y2floatThe y2.
xlocsimple stringdefault xloc.bar_indexThe xloc.
extendstringdefault extend.noneThe extend.
colorcolordefault color.blueThe colour.
stylestringdefault line.style_solidThe style constant.
widthintdefault 1The width.
force_overlayconst booldefault falseAccepted and ignored in this version.
lookconst stringdefault ""The look.
first_pointpointThe first point.
second_pointpointThe second point.

Returns line.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
colorcolorThe colour.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
extendstringThe extend.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
pointpointThe point.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
pointpointThe point.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
stylestringThe style constant.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
widthintThe width.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
xintThe value.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
xintThe value.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
x1intThe x1.
x2intThe x2.
xlocstringThe xloc.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
xintThe value.
yfloatThe y.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
xintThe value.
yfloatThe y.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
yfloatThe y.

Example

ChartScriptFragmentOpen in editor
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)
ParameterTypeDescription
idlineThe array.
yfloatThe y.

Example

ChartScriptFragmentOpen in editor
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

ChartScriptFragmentOpen in editor
const n = array.size(line.all)

Since ChartScript 1

#Constants

NameTypeDescription
line.style_arrow_bothstringLine dash / arrow style.
line.style_arrow_leftstringLine dash / arrow style.
line.style_arrow_rightstringLine dash / arrow style.
line.style_dashedstringLine dash / arrow style.
line.style_dottedstringLine dash / arrow style.
line.style_solidstringLine dash / arrow style.

The ChartScript documentation is in English for now; translations will follow.