Skip to content
Nexus Prop LLC

NexuScript 1.5

Plotting and drawing

Plots, shading, lines, boxes, labels, markers, tables and the chart's own candles.

plot

functionNexuScript 1.0

Draws one value per bar as a line, steps, an area, bars or dots.

Syntax

plot(title::String, value::Number, color::Color = automatic, width::Number = 1, style::String = "line", dash::String = "solid", base::Number = automatic, scale::Bool = true, legend::Bool = true, offset::Number = 0, tooltip::String = automatic, z::Number = 0, price_line::Bool = false, value_label::Bool = false, top_color::Color = automatic, bottom_color::Color = automatic)

Parameters

NameTypeDefaultDescription
titleStringfixedrequiredThe plot's name, shown in the legend. It is also how the chart tells plots apart, so every plot and candle needs its own title. Fixed.
valueNumberrequiredThe number to draw on this bar. missing leaves a gap.
colorColorautomaticThe colour on this bar. It may change from bar to bar, so a condition such as close > open ? color.green : color.red colours each bar on its own. The colour of the first call is the one the legend shows. Left out, the plot is blue.
widthNumberfixed1How thick the line is, from 1 to 10. Fixed.
styleStringfixed"line"How the values are drawn. "line" joins them with a line, "step" draws flat steps that jump at each bar, "area" fills the space under the line, "histogram" draws a thin bar from the base to each value, "columns" draws wide bars from the base, "dots" puts a dot on each value and "cross" puts a small cross on each value. Fixed. One of "line", "step", "area", "histogram", "columns", "dots", "cross".
dashStringfixed"solid"The line pattern: "solid", "dashed" or "dotted". Fixed. One of "solid", "dashed", "dotted".
baseNumberfixedautomaticWhere histograms, columns and areas start, such as 0. Left out, the chart picks the bottom of the pane. Fixed.
scaleBoolfixedtruefalse keeps the plot from stretching the price scale, so a far away value does not squash the candles. Fixed.
legendBoolfixedtruefalse hides the plot from the legend. Fixed.
offsetNumberfixed0Shifts the drawn line this many bars to the right, or to the left when negative. A whole number from -500 to 500. Fixed.
tooltipStringfixedautomaticWords shown when the pointer rests on the plot. Fixed: one text for the whole plot (an input, a constant or a literal). Left out or empty, there is no tooltip. New in 1.4.
zNumberfixed0The drawing order among this script's drawings, a whole number from -100 to 100; higher is drawn later, so it sits on top. Drawings with the same z keep their usual order: fills, plots, candles, lines and boxes, vertical lines, levels, marks. 0 when left out. Fixed. New in 1.4.
price_lineBoolfixedfalsetrue draws a thin dashed line across the pane at the plot's newest value, in the plot's colour, the way the chart marks the last price. Fixed. New in 1.4.
value_labelBoolfixedfalsetrue shows the plot's newest value as a tag on the price axis, in the plot's colour. Fixed. New in 1.4.
top_colorColorfixedautomaticFor style = "area": the colour of the fill at the line. With bottom_color it makes a true two-colour gradient down to the base. Left out, the area fades from the plot colour. Fixed. New in 1.4.
bottom_colorColorfixedautomaticFor style = "area": the colour of the fill at the base. Left out, the gradient ends in top_color made almost clear. Fixed. New in 1.4.

Details

Call plot with the same title on every bar to build one line. Options marked fixed are read on the first call and must be a literal, an input or a constant. For a see-through colour, wrap it in color.fade: color.fade(color.blue, 70) is blue at 70% transparency. A script may draw at most 128 plots and candles together. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Missing values

A missing value leaves a gap in the line on that bar.

Live and historical bars

On the newest bar the value is drawn again on every update until the bar closes.

Errors

  • NS302a fixed option such as width or style is given a value that changes from bar to bar
  • NS310the script draws more than 128 plots and candles
  • NS430two plots, or a plot and a candle, share one title

Examples

let avg = ta.sma(close, 20)
plot("Average", avg, color = close > avg ? color.green : color.red, width = 2)
plot("Body", close - open, style = "columns", base = 0, color = close >= open ? color.fade(color.green, 40) : color.fade(color.red, 40))
plot("Close", close, tooltip = "The bar's closing price", price_line = true, value_label = true, z = 2)
plot("Volume", volume, style = "area", top_color = color.fade(color.teal, 30), bottom_color = color.fade(color.teal, 95), scale = false)

See also

bandcandlelevelvlinecolor.fade

band

functionNexuScript 1.0

Shades the space between two plots on this bar.

Syntax

band(a::String, b::String, color::Color = automatic, top_color::Color = automatic, bottom_color::Color = automatic, z::Number = 0)

Parameters

NameTypeDefaultDescription
aStringfixedrequiredThe title of the first plot. Fixed.
bStringfixedrequiredThe title of the second plot. Fixed.
colorColorautomaticThe shading on this bar. It may change from bar to bar. Left out, the band takes the first plot's colour at 12% opacity.
top_colorColorautomaticThe colour at the higher edge of the fill on this bar. With bottom_color it makes a true two-colour gradient between the two plots; given alone, both edges take it. It may change from bar to bar. New in 1.4.
bottom_colorColorautomaticThe colour at the lower edge of the fill on this bar. Given alone, both edges take it. New in 1.4.
zNumberfixed0The drawing order among this script's drawings, a whole number from -100 to 100; higher is drawn later, so it sits on top. Drawings with the same z keep their usual order: fills, plots, candles, lines and boxes, vertical lines, levels, marks. 0 when left out. Fixed. New in 1.4.

Details

Both plots must be drawn with plot somewhere in the script. A bar where band is not called is left unshaded. A script may draw at most 128 bands. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Missing values

Where either plot has a gap, there is nothing to shade.

Errors

  • NS431a title given to band is never drawn by any plot (found at the end of the run)
  • NS310the script draws more than 128 bands

Example

let (basis, upper, lower) = ta.bands(close, 20, 2.0)
plot("Upper", upper)
plot("Lower", lower)
band("Upper", "Lower", color = color.fade(color.blue, 85))

See also

plotcolor.fadebackground

marker

functionNexuScript 1.0

Puts a label, arrow or shape on this bar or on another bar.

Syntax

marker(text::String = "", position::String = "above", price::Number = automatic, shape::String = "label", color::Color = automatic, text_color::Color = automatic, size::String = "small", time::Number = automatic, tooltip::String = automatic, z::Number = 0)

Parameters

NameTypeDefaultDescription
textString""The words to show. Leave it empty for a shape with no words.
positionString"above"Where the mark sits: "above" the bar or "below" it. One of "above", "below".
priceNumberautomaticCentres the mark on this price instead of above or below the bar.
shapeString"label"The look: "label", "arrow_up", "arrow_down", "triangle_up", "triangle_down", "circle", "cross" or "text", and from 1.4 also "square", "diamond", "flag" and "plus". The "text" shape needs some text. One of "label", "arrow_up", "arrow_down", "triangle_up", "triangle_down", "circle", "cross", "text", "square", "diamond", "flag", "plus".
colorColorautomaticThe colour of the shape. Left out, it is blue.
text_colorColorautomaticThe colour of the words. Left out, the chart picks one that reads well.
sizeString"small"How big the mark is: "tiny", "small", "normal" or "large". One of "tiny", "small", "normal", "large".
timeNumberautomaticPuts the mark on the bar at this time instead of this bar. It may be in the past or the future; a future time needs price too.
tooltipStringautomaticWords shown when the pointer rests on the mark. Left out or empty, there is no tooltip. New in 1.4.
zNumber0The drawing order among this script's drawings, a whole number from -100 to 100; higher is drawn later, so it sits on top. Drawings with the same z keep their usual order: fills, plots, candles, lines and boxes, vertical lines, levels, marks. 0 when left out. New in 1.4.

Details

The newest 10,000 marks are kept; older ones are dropped quietly. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Units and time zones

time is a bar time in milliseconds, like time. price is in the symbol's quote currency.

Missing values

A missing price or time is ignored: the mark goes above or below this bar as if it was left out.

Errors

  • NS210the shape is "text" but the text is empty

Examples

let up = ta.crossover(close, ta.sma(close, 20))
if up
    marker("Buy", position = "below", shape = "arrow_up", color = color.green)
end
if bar.index % 20 == 0
    marker("", shape = "diamond", color = color.purple, tooltip = "Every twentieth bar: $(close)", z = 1)
end

See also

alertlinevlinetime

line

functionNexuScript 1.0

Draws a straight line between two points placed by time and price.

Syntax

line(time1::Number, price1::Number, time2::Number, price2::Number, color::Color = automatic, width::Number = 1, dash::String = "solid", extend::String = "none", z::Number = 0)

Parameters

NameTypeDefaultDescription
time1NumberrequiredThe time of the first point.
price1NumberrequiredThe price of the first point.
time2NumberrequiredThe time of the second point.
price2NumberrequiredThe price of the second point.
colorColorautomaticThe line colour. Left out, it is blue.
widthNumber1How thick the line is, from 1 to 10.
dashString"solid"The line pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted".
extendString"none"Carries the line past its points: "none", "left", "right" or "both". One of "none", "left", "right", "both".
zNumber0The drawing order among this script's drawings, a whole number from -100 to 100; higher is drawn later, so it sits on top. Drawings with the same z keep their usual order: fills, plots, candles, lines and boxes, vertical lines, levels, marks. 0 when left out. New in 1.4.

Details

Each call draws a new line. The newest 2,000 lines, boxes, polylines and vertical lines together are kept; older ones are dropped quietly. To draw one line that moves, call it only on the last bar (if bar.last). It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Units and time zones

Times are bar times in milliseconds, such as time or time[10]. Prices are in the symbol's quote currency.

Missing values

A missing time or price stops the script with NS210, so check it with ismissing first.

Errors

  • NS210a time or a price is missing or not a number

Example

if bar.last
    line(time[20], close[20], time, close, color = color.orange, width = 2, extend = "right")
end

See also

boxpolylinelevelbar.last

box

functionNexuScript 1.0

Draws a rectangle between two corners placed by time and price.

Syntax

box(time1::Number, price1::Number, time2::Number, price2::Number, color::Color = automatic, fill::Color = automatic, width::Number = 1, dash::String = "solid", extend::String = "none", tooltip::String = automatic, z::Number = 0)

Parameters

NameTypeDefaultDescription
time1NumberrequiredThe time of the first corner.
price1NumberrequiredThe price of the first corner.
time2NumberrequiredThe time of the opposite corner.
price2NumberrequiredThe price of the opposite corner.
colorColorautomaticThe border colour. Left out with no fill either, the border is blue.
fillColorautomaticThe colour inside the box. Left out, the inside is clear.
widthNumber1How thick the border is, from 1 to 10.
dashString"solid"The border pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted".
extendString"none"Carries the box past its corners: "none", "left", "right" or "both". One of "none", "left", "right", "both".
tooltipStringautomaticWords shown when the pointer rests inside the box. Left out or empty, there is no tooltip. New in 1.4.
zNumber0The drawing order among this script's drawings, a whole number from -100 to 100; higher is drawn later, so it sits on top. Drawings with the same z keep their usual order: fills, plots, candles, lines and boxes, vertical lines, levels, marks. 0 when left out. New in 1.4.

Details

Each call draws a new box. The newest 2,000 lines, boxes, polylines and vertical lines together are kept; older ones are dropped quietly. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Units and time zones

Times are bar times in milliseconds. Prices are in the symbol's quote currency.

Missing values

A missing time or price stops the script with NS210, so check it with ismissing first.

Errors

  • NS210a time or a price is missing or not a number

Example

let hi = ta.highest(high, 12)
let lo = ta.lowest(low, 12)
if bar.last
    box(time[11], hi, time, lo, color = color.blue, fill = color.fade(color.blue, 85))
end

See also

linepolylinebackground

polyline

functionNexuScript 1.0

Draws one line through a list of points, open or closed into a shape.

Syntax

polyline(title::String, times::Array{Number}, prices::Array{Number}, color::Color = automatic, width::Number = 1, dash::String = "solid", closed::Bool = false, fill::Color = automatic, z::Number = 0)

Parameters

NameTypeDefaultDescription
titleStringfixedrequiredA name for the shape. Fixed.
timesArray{Number}requiredThe time of each point, in order.
pricesArray{Number}requiredThe price of each point, in the same order as times.
colorColorautomaticThe line colour. Left out, it is blue.
widthNumber1How thick the line is, from 1 to 10.
dashString"solid"The line pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted".
closedBoolfalsetrue joins the last point back to the first.
fillColorautomaticThe colour inside a closed shape. Left out, the inside is clear.
zNumber0The drawing order among this script's drawings, a whole number from -100 to 100; higher is drawn later, so it sits on top. Drawings with the same z keep their usual order: fills, plots, candles, lines and boxes, vertical lines, levels, marks. 0 when left out. New in 1.4.

Details

Point i is (times[i], prices[i]), so both arrays must be the same length. The newest 2,000 lines, boxes, polylines and vertical lines together are kept. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Units and time zones

Times are bar times in milliseconds. Prices are in the symbol's quote currency.

Missing values

A point with a missing time or price is skipped by the chart.

Errors

  • NS432times and prices have different lengths

Example

if bar.last
    polyline("Last five closes", [time[4], time[3], time[2], time[1], time], [close[4], close[3], close[2], close[1], close], color = color.purple, width = 2)
end

See also

lineboxArray

background

functionNexuScript 1.0

Tints the chart behind this bar.

Syntax

background(color::Color)

Parameters

NameTypeDefaultDescription
colorColorrequiredThe tint. Use color.fade so the candles still show through.

Details

Only the bars where it is called are tinted. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Missing values

It takes a colour, never a number, so it never sees missing.

Example

let rsi = ta.rsi(close, 14)
if rsi > 70
    background(color.fade(color.red, 85))
end

See also

candle_colorbandcolor.fade

candle_color

functionNexuScript 1.0

Colours the chart's own candle on this bar.

Syntax

candle_color(color::Color, wick::Color = automatic, border::Color = automatic)

Parameters

NameTypeDefaultDescription
colorColorrequiredThe body colour.
wickColorautomaticThe wick colour. Left out, the chart keeps its own.
borderColorautomaticThe border colour. Left out, the chart keeps its own.

Details

It works for scripts drawn over the price on a candle chart. Bars where it is not called keep their usual colours. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Missing values

It takes colours, never numbers, so it never sees missing.

Example

let busy = volume > ta.sma(volume, 20) * 2
if busy
    candle_color(color.yellow, wick = color.yellow)
end

See also

candlebackground

candle

functionNexuScript 1.0

Draws a candle on each bar from the script's own open, high, low and close.

Syntax

candle(title::String, open::Number, high::Number, low::Number, close::Number, color::Color = automatic, wick::Color = automatic, border::Color = automatic, up::Color = automatic, down::Color = automatic, legend::Bool = true, scale::Bool = true)

Parameters

NameTypeDefaultDescription
titleStringfixedrequiredThe name, shown in the legend. A candle counts as a plot, so no plot or other candle may share it. Fixed.
openNumberrequiredThe candle's open on this bar.
highNumberrequiredThe candle's high on this bar.
lowNumberrequiredThe candle's low on this bar.
closeNumberrequiredThe candle's close on this bar.
colorColorautomaticThe body colour on this bar. It may change from bar to bar.
wickColorautomaticThe wick colour on this bar.
borderColorautomaticThe border colour on this bar.
upColorautomaticThe body colour for candles that close up, used where color is not given. Read on the first call.
downColorautomaticThe body colour for candles that close down, used where color is not given. Read on the first call.
legendBoolfixedtruefalse hides the candles from the legend. Fixed.
scaleBoolfixedtruefalse keeps the candles from stretching the price scale. Fixed.

Details

A script may draw at most 128 plots and candles together. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Units and time zones

Prices in the symbol's quote currency.

Missing values

A bar with a missing price draws no candle.

Errors

  • NS310the script draws more than 128 plots and candles
  • NS430a candle shares its title with a plot

Example

candle("Smoothed", ta.sma(open, 3), ta.sma(high, 3), ta.sma(low, 3), ta.sma(close, 3), color = close >= open ? color.green : color.red)

See also

plotcandle_color

table

functionNexuScript 1.0

Shows a small panel of text in a corner of the chart.

Syntax

table(rows::Array, position::String = "top_right", color::Color = automatic, background::Color = automatic, size::String = "small")

Parameters

NameTypeDefaultDescription
rowsArrayrequiredThe rows to show. Each row is an array of cells, and a cell is text, a number, a bool or a cell(...). A plain array of values shows one cell per row.
positionString"top_right"Where the panel sits: "top_right", "top_left", "bottom_right" or "bottom_left", and from 1.4 also "top_center", "bottom_center", "middle_left", "middle_right" and "middle_center". One of "top_right", "top_left", "bottom_right", "bottom_left", "top_center", "bottom_center", "middle_left", "middle_right", "middle_center".
colorColorautomaticThe text colour for every cell that does not set its own.
backgroundColorautomaticThe panel's background colour.
sizeString"small"The text size: "tiny", "small", "normal" or "large". One of "tiny", "small", "normal", "large".

Details

Only the newest bar's table is shown, so a table drawn on every bar always shows the latest values. A table holds at most 30 rows and 10 cells per row; text longer than 100 characters in a cell is cut short. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Missing values

A missing number in a cell shows as missing.

Errors

  • NS433the table has more than 30 rows or a row has more than 10 cells

Examples

table([["Close", "$(close)"], ["Bar", "$(bar.index)"]], position = "top_left")
let rsi = ta.rsi(close, 14)
table([[cell("RSI"), cell("$(round(rsi, digits = 1))", color = rsi > 70 ? color.red : color.green)]])
if bar.last
    table([["Session", clock.countdown]], position = "top_center", size = "normal")
end

See also

cellprintstring

cell

functionNexuScript 1.0

Builds one table cell with its own text colour and background.

Syntax

cell(text::String, color::Color = automatic, background::Color = automatic) -> Cell

Parameters

NameTypeDefaultDescription
textStringrequiredThe words in the cell.
colorColorautomaticThe text colour. Left out, the table's colour is used.
backgroundColorautomaticThe cell's background. Left out, the table's background shows.

Returns

Cell A cell to put in a row of table.

Details

Use it when one cell needs to stand out. Plain text, numbers and bools also work as cells. To show a number, put it in text first: "$(close)".

Missing values

It takes text and colours, never numbers, so it never sees missing.

Example

let up = close >= open
table([[cell("Bar"), cell(up ? "Up" : "Down", background = up ? color.green : color.red)]])

See also

tablestring

level

functionNexuScript 1.0

Draws a fixed horizontal line across the whole pane.

Syntax

level "Title", value, color = color.gray, style = "dashed"

Parameters

NameTypeDefaultDescription
titleString""An optional name for the line. Leave it out to write just level 50.
valueNumberrequiredThe price or value where the line sits. It must be fixed: a number, an input or a constant.
colorColorautomaticThe line colour. Left out, it is a neutral gray.
styleString"dashed"The line pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted".

Details

A level is written in setup, outside on bar, because it never changes from bar to bar. It suits oscillators: zero lines, overbought and oversold. A script may have at most 128 levels.

Missing values

The value must be a real number: a missing value stops the script with NS210.

Errors

  • NS302the value changes from bar to bar
  • NS310the script has more than 128 levels

Examples

level "Zero", 0
level "Overbought", 70, color = color.red, style = "dotted"
level 30

See also

plotlineinputconst

shade

functionNexuScript 1.3

Shades the space between any two values on this bar, such as a line and a fixed level.

Syntax

shade(title::String, top::Number, bottom::Number, color::Color = automatic, scale::Bool = true, top_color::Color = automatic, bottom_color::Color = automatic, z::Number = 0)

Parameters

NameTypeDefaultDescription
titleStringfixedrequiredA name for the shading. It also names the two hidden plots it draws, "<title> (top)" and "<title> (bottom)". Fixed.
topNumberrequiredOne edge of the shading on this bar: any number, such as a plot's value, a moving average or a fixed price. missing leaves a gap.
bottomNumberrequiredThe other edge on this bar. It may sit above top; the space between them is shaded either way. missing leaves a gap.
colorColorautomaticThe shading on this bar. It may change from bar to bar; for a gradient look, pick it with color.gradient. Left out, it is blue at 20% opacity.
scaleBoolfixedtruefalse keeps the shading from stretching the price scale, so a far away edge does not squash the candles. Fixed.
top_colorColorautomaticThe colour at the higher edge on this bar. With bottom_color it makes a true two-colour gradient between the two values; given alone, both edges take it. It may change from bar to bar. New in 1.4.
bottom_colorColorautomaticThe colour at the lower edge on this bar. Given alone, both edges take it. New in 1.4.
zNumberfixed0The drawing order among this script's drawings, a whole number from -100 to 100; higher is drawn later, so it sits on top. Drawings with the same z keep their usual order: fills, plots, candles, lines and boxes, vertical lines, levels, marks. 0 when left out. Fixed. New in 1.4.

Details

Unlike band, the edges do not have to be plots of their own. shade draws two hidden plots (no legend, invisible) and fills between them, so those two names count toward the 128 plots and candles a script may draw, and they must not match a title you use for plot or candle. Call it with the same title on every bar to build one shaded area. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Missing values

A missing top or bottom leaves that bar unshaded.

Live and historical bars

On the newest bar the shading is drawn again on every update until the bar closes.

Errors

  • NS210the title is empty
  • NS230it is called in setup or inside a higher block
  • NS310the script draws more than 128 plots and candles, the hidden ones included
  • NS430"<title> (top)" or "<title> (bottom)" is also the title of another plot or candle

Examples

let avg = ta.sma(close, 20)
shade("Above average", close, avg, color = close > avg ? color.fade(color.green, 80) : color.fade(color.red, 80))
let rsi = ta.rsi(close, 14)
plot("RSI", rsi)
shade("Hot zone", rsi, 70, color = rsi > 70 ? color.fade(color.red, 70) : color.none)
shade("Range", high, low, top_color = color.fade(color.green, 75), bottom_color = color.fade(color.red, 75), z = -1)

See also

bandplotcolor.gradientlevel

hline

functionNexuScript 1.3

Draws a horizontal line at a price, starting at this bar.

Syntax

hline(price::Number, color::Color = automatic, width::Number = 1, dash::String = "solid", extend::String = "right", z::Number = 0)

Parameters

NameTypeDefaultDescription
priceNumberrequiredThe price where the line sits.
colorColorautomaticThe line colour. Left out, it is blue.
widthNumber1How thick the line is, from 1 to 10.
dashString"solid"The line pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted".
extendString"right"How far it runs: "right" (the default) from this bar to the right edge of the chart, "both" across the whole chart, and "none" only across this one bar. "left" runs from this bar to the left edge. One of "none", "left", "right", "both".
zNumber0The drawing order among this script's drawings, a whole number from -100 to 100; higher is drawn later, so it sits on top. Drawings with the same z keep their usual order: fills, plots, candles, lines and boxes, vertical lines, levels, marks. 0 when left out. New in 1.4.

Details

Each call draws a new line, like line. The newest 2,000 lines, boxes, polylines and vertical lines together are kept; older ones are dropped quietly. For one line, call it on one bar only, for example inside if bar.last. For a fixed line across the whole pane that never moves, level is simpler. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Units and time zones

The price is in the symbol's quote currency. The line starts at the bar's opening time.

Missing values

A missing price draws nothing.

Errors

  • NS230it is called in setup or inside a higher block

Example

let top = ta.highest(high, 50)
if bar.last
    hline(top, color = color.orange, dash = "dashed")
end

See also

linelevelbar.last

vline

functionNexuScript 1.4

Draws a vertical line the full height of the pane at a time.

Syntax

vline(time::Number = automatic, color::Color = automatic, width::Number = 1, dash::String = "solid", z::Number = 0)

Parameters

NameTypeDefaultDescription
timeNumberautomaticThe bar time the line stands on. Left out, it is this bar. It may be in the past or the future.
colorColorautomaticThe line colour. Left out, it is blue.
widthNumber1How thick the line is, from 1 to 10.
dashString"solid"The line pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted".
zNumber0The drawing order among this script's drawings, a whole number from -100 to 100; higher is drawn later, so it sits on top. 0 when left out.

Details

Unlike line, which runs between two prices, a vertical line always spans the whole pane, however the price scale moves. Each call draws a new line; the newest 2,000 lines, boxes, polylines and vertical lines together are kept, older ones are dropped quietly. For one line that marks an event, call it on the bar where the event happens. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.

Units and time zones

time is a bar time in milliseconds, like time.

Missing values

A missing time draws the line on this bar.

Errors

  • NS210z is not a whole number from -100 to 100
  • NS230it is called in setup or inside a higher block

Examples

if session.starts("0930-1600")
    vline(color = color.fade(color.gray, 40), dash = "dashed")
end
if bar.last
    vline(time, color = color.orange, width = 2, z = 5)
end

See also

linehlinelevelsession.startsbackground