NexuScript 1.5
Plotting and drawing
Plots, shading, lines, boxes, labels, markers, tables and the chart's own candles.
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
| Name | Type | Default | Description |
|---|---|---|---|
title | Stringfixed | required | The 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. |
value | Number | required | The number to draw on this bar. missing leaves a gap. |
color | Color | automatic | The 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. |
width | Numberfixed | 1 | How thick the line is, from 1 to 10. Fixed. |
style | Stringfixed | "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". |
dash | Stringfixed | "solid" | The line pattern: "solid", "dashed" or "dotted". Fixed. One of "solid", "dashed", "dotted". |
base | Numberfixed | automatic | Where histograms, columns and areas start, such as 0. Left out, the chart picks the bottom of the pane. Fixed. |
scale | Boolfixed | true | false keeps the plot from stretching the price scale, so a far away value does not squash the candles. Fixed. |
legend | Boolfixed | true | false hides the plot from the legend. Fixed. |
offset | Numberfixed | 0 | Shifts the drawn line this many bars to the right, or to the left when negative. A whole number from -500 to 500. Fixed. |
tooltip | Stringfixed | automatic | Words 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. |
z | Numberfixed | 0 | The 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_line | Boolfixed | false | true 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_label | Boolfixed | false | true shows the plot's newest value as a tag on the price axis, in the plot's colour. Fixed. New in 1.4. |
top_color | Colorfixed | automatic | For 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_color | Colorfixed | automatic | For 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
widthorstyleis 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
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
| Name | Type | Default | Description |
|---|---|---|---|
a | Stringfixed | required | The title of the first plot. Fixed. |
b | Stringfixed | required | The title of the second plot. Fixed. |
color | Color | automatic | The 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_color | Color | automatic | The 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_color | Color | automatic | The colour at the lower edge of the fill on this bar. Given alone, both edges take it. New in 1.4. |
z | Numberfixed | 0 | The 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
bandis 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
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
| Name | Type | Default | Description |
|---|---|---|---|
text | String | "" | The words to show. Leave it empty for a shape with no words. |
position | String | "above" | Where the mark sits: "above" the bar or "below" it. One of "above", "below". |
price | Number | automatic | Centres the mark on this price instead of above or below the bar. |
shape | String | "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". |
color | Color | automatic | The colour of the shape. Left out, it is blue. |
text_color | Color | automatic | The colour of the words. Left out, the chart picks one that reads well. |
size | String | "small" | How big the mark is: "tiny", "small", "normal" or "large". One of "tiny", "small", "normal", "large". |
time | Number | automatic | Puts 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. |
tooltip | String | automatic | Words shown when the pointer rests on the mark. Left out or empty, there is no tooltip. New in 1.4. |
z | Number | 0 | The 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
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)
endif bar.index % 20 == 0
marker("", shape = "diamond", color = color.purple, tooltip = "Every twentieth bar: $(close)", z = 1)
endSee also
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
| Name | Type | Default | Description |
|---|---|---|---|
time1 | Number | required | The time of the first point. |
price1 | Number | required | The price of the first point. |
time2 | Number | required | The time of the second point. |
price2 | Number | required | The price of the second point. |
color | Color | automatic | The line colour. Left out, it is blue. |
width | Number | 1 | How thick the line is, from 1 to 10. |
dash | String | "solid" | The line pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted". |
extend | String | "none" | Carries the line past its points: "none", "left", "right" or "both". One of "none", "left", "right", "both". |
z | Number | 0 | The 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")
endSee also
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
| Name | Type | Default | Description |
|---|---|---|---|
time1 | Number | required | The time of the first corner. |
price1 | Number | required | The price of the first corner. |
time2 | Number | required | The time of the opposite corner. |
price2 | Number | required | The price of the opposite corner. |
color | Color | automatic | The border colour. Left out with no fill either, the border is blue. |
fill | Color | automatic | The colour inside the box. Left out, the inside is clear. |
width | Number | 1 | How thick the border is, from 1 to 10. |
dash | String | "solid" | The border pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted". |
extend | String | "none" | Carries the box past its corners: "none", "left", "right" or "both". One of "none", "left", "right", "both". |
tooltip | String | automatic | Words shown when the pointer rests inside the box. Left out or empty, there is no tooltip. New in 1.4. |
z | Number | 0 | The 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))
endSee also
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
| Name | Type | Default | Description |
|---|---|---|---|
title | Stringfixed | required | A name for the shape. Fixed. |
times | Array{Number} | required | The time of each point, in order. |
prices | Array{Number} | required | The price of each point, in the same order as times. |
color | Color | automatic | The line colour. Left out, it is blue. |
width | Number | 1 | How thick the line is, from 1 to 10. |
dash | String | "solid" | The line pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted". |
closed | Bool | false | true joins the last point back to the first. |
fill | Color | automatic | The colour inside a closed shape. Left out, the inside is clear. |
z | Number | 0 | The 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
- NS432
timesandpriceshave 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)
endSee also
Tints the chart behind this bar.
Syntax
background(color::Color)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
color | Color | required | The tint. Use color.fade so the candles still show through. |
Details
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))
endSee also
Colours the chart's own candle on this bar.
Syntax
candle_color(color::Color, wick::Color = automatic, border::Color = automatic)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
color | Color | required | The body colour. |
wick | Color | automatic | The wick colour. Left out, the chart keeps its own. |
border | Color | automatic | The 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)
endSee also
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
| Name | Type | Default | Description |
|---|---|---|---|
title | Stringfixed | required | The name, shown in the legend. A candle counts as a plot, so no plot or other candle may share it. Fixed. |
open | Number | required | The candle's open on this bar. |
high | Number | required | The candle's high on this bar. |
low | Number | required | The candle's low on this bar. |
close | Number | required | The candle's close on this bar. |
color | Color | automatic | The body colour on this bar. It may change from bar to bar. |
wick | Color | automatic | The wick colour on this bar. |
border | Color | automatic | The border colour on this bar. |
up | Color | automatic | The body colour for candles that close up, used where color is not given. Read on the first call. |
down | Color | automatic | The body colour for candles that close down, used where color is not given. Read on the first call. |
legend | Boolfixed | true | false hides the candles from the legend. Fixed. |
scale | Boolfixed | true | false keeps the candles from stretching the price scale. Fixed. |
Details
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
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
| Name | Type | Default | Description |
|---|---|---|---|
rows | Array | required | The 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. |
position | String | "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". |
color | Color | automatic | The text colour for every cell that does not set its own. |
background | Color | automatic | The panel's background colour. |
size | String | "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")
endSee also
Builds one table cell with its own text colour and background.
Syntax
cell(text::String, color::Color = automatic, background::Color = automatic) -> CellParameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | required | The words in the cell. |
color | Color | automatic | The text colour. Left out, the table's colour is used. |
background | Color | automatic | The 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
Draws a fixed horizontal line across the whole pane.
Syntax
level "Title", value, color = color.gray, style = "dashed"Parameters
| Name | Type | Default | Description |
|---|---|---|---|
title | String | "" | An optional name for the line. Leave it out to write just level 50. |
value | Number | required | The price or value where the line sits. It must be fixed: a number, an input or a constant. |
color | Color | automatic | The line colour. Left out, it is a neutral gray. |
style | String | "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", 0level "Overbought", 70, color = color.red, style = "dotted"
level 30See also
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
| Name | Type | Default | Description |
|---|---|---|---|
title | Stringfixed | required | A name for the shading. It also names the two hidden plots it draws, "<title> (top)" and "<title> (bottom)". Fixed. |
top | Number | required | One 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. |
bottom | Number | required | The other edge on this bar. It may sit above top; the space between them is shaded either way. missing leaves a gap. |
color | Color | automatic | The 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. |
scale | Boolfixed | true | false keeps the shading from stretching the price scale, so a far away edge does not squash the candles. Fixed. |
top_color | Color | automatic | The 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_color | Color | automatic | The colour at the lower edge on this bar. Given alone, both edges take it. New in 1.4. |
z | Numberfixed | 0 | The 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
higherblock - 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
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
| Name | Type | Default | Description |
|---|---|---|---|
price | Number | required | The price where the line sits. |
color | Color | automatic | The line colour. Left out, it is blue. |
width | Number | 1 | How thick the line is, from 1 to 10. |
dash | String | "solid" | The line pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted". |
extend | String | "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". |
z | Number | 0 | The 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
higherblock
Example
let top = ta.highest(high, 50)
if bar.last
hline(top, color = color.orange, dash = "dashed")
endSee also
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
| Name | Type | Default | Description |
|---|---|---|---|
time | Number | automatic | The bar time the line stands on. Left out, it is this bar. It may be in the past or the future. |
color | Color | automatic | The line colour. Left out, it is blue. |
width | Number | 1 | How thick the line is, from 1 to 10. |
dash | String | "solid" | The line pattern: "solid", "dashed" or "dotted". One of "solid", "dashed", "dotted". |
z | Number | 0 | The 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
- NS210
zis not a whole number from -100 to 100 - NS230it is called in setup or inside a
higherblock
Examples
if session.starts("0930-1600")
vline(color = color.fade(color.gray, 40), dash = "dashed")
endif bar.last
vline(time, color = color.orange, width = 2, z = 5)
end