Functions
line.new()
Creates a line between two points. Coordinates can be passed as x1/y1/x2/y2 or as chart.point first_point/second_point.
Syntax · 1 of 2
line.new(series int x1, series float y1, series int x2, series float y2, series string xloc, series string extend, series color color, series string style, series int width, const bool forceOverlay) → series line
Arguments
x1 required series int X-coordinate of the first point (bar index or time, depending on xloc). y1 required series float Y-coordinate (price) of the first point. x2 required series int X-coordinate of the second point. y2 required series float Y-coordinate (price) of the second point. xloc series string xloc.bar_index or xloc.bar_time. Default is bar_index. extend series string extend.none, left, right, or both. Default is none. color series color Line color. Optional. style series string line.style_* constant. Optional. width series int Line width in pixels. Optional. forceOverlay const bool If true, draw on the main pane even when the script is not overlay. Return Type
series line Syntax · 2 of 2
line.new(series chartPoint first_point, series chartPoint second_point, series string xloc, series string extend, series color color, series string style, series int width, const bool forceOverlay) → series line
Arguments
first_point required series chartPoint Optional chart.point for the first endpoint (alternative to x1/y1). second_point required series chartPoint Optional chart.point for the second endpoint (alternative to x2/y2). xloc series string xloc.bar_index or xloc.bar_time. Default is bar_index. extend series string extend.none, left, right, or both. Default is none. color series color Line color. Optional. style series string line.style_* constant. Optional. width series int Line width in pixels. Optional. forceOverlay const bool If true, draw on the main pane even when the script is not overlay. Return Type
series line Example
//@lipi=2
indicator("line.new Example", overlay=true)
if barstate.islast {
line.new(bar_index[10], high[10], bar_index, high, color=color.red, width=2, style=line.style_solid, extend=extend.none)
}