Appearance
Plots
How do you show a script's values on the chart? Call plot with a series for a line, plotshape or plotchar for a mark on the bars where a condition holds, hline for a fixed level, fill between two of those, and bgcolor or barcolor to colour the chart behind or on each bar. Each call draws one point per bar it runs on, and a na value or colour leaves that bar empty.
pine
//@version=6
indicator("Trend colours", overlay = true)
float ma = ta.ema(close, 50)
bool up = close > ma
// A colour worked out per bar colours each bar's piece of the line on its own.
p1 = plot(ma, "EMA 50", color = up ? color.teal : color.red, linewidth = 2)
p2 = plot(close, "Close", display = display.none)
fill(p1, p2, color = up ? color.new(color.teal, 85) : color.new(color.red, 85))
bgcolor(ta.cross(close, ma) ? color.new(color.yellow, 80) : na,
title = "Crosses")Plots draw on the price pane when the declaration says overlay = true, and in the script's own pane otherwise. On a run that only computes, such as a sweep or a screen, plots aren't drawn and their arguments don't run, unless something in them can change what the run computes. In leak-safe AmenoScript a negative offset stops the script, since it draws each bar's value on a bar before it, and a Pine text gets a warning. See plots.
plot
pine
plot(series, title, color, linewidth, style, trackprice, histbase, offset, join, editable, show_last, display, format, precision, force_overlay, linestyle) → plotDraws a series as a line, histogram, area, columns or marks, and returns a reference fill can take.
A value of na, or 1e100 and beyond in either direction, leaves the bar empty, while the script still reads the value. A colour that isn't a literal is worked out on every bar, so each bar's piece can differ, and a na colour leaves that piece undrawn. Two plots with one title both draw: the second keeps its own key. A plot whose display has no pane bit, display.none or display.data_window, isn't drawn, but fill can still use it and the data window still lists it. A plot with editable = false has no row in the study's Style settings.
| Parameter | Default | Description |
|---|---|---|
seriesseries int/float | The values to draw. | |
titleconst string | The plot's name in the legend, the settings and the data window. | |
colorseries color | #2962FF | A fixed colour, or one worked out per bar. |
linewidthinput int | 1 | The line's width in pixels. |
styleinput plot_style | plot.style_line | One of the plot.style_* values below. |
trackpriceinput bool | false | true draws a horizontal line at the last value across the pane. |
histbaseinput int/float | 0 | The level histograms, columns and areas start from. |
offsetseries int | 0 | Shifts the plot this many bars right, or left when negative. |
joininput bool | false | true joins the marks of plot.style_circles and plot.style_cross with a line. |
editableconst bool | true | false leaves the plot out of the Style settings. |
show_lastinput int | Draws only the last this-many bars. | |
displayinput plot_display | display.all | Where the plot shows: see display.*. Without the pane bit, it isn't drawn. |
formatinput string | How its values read: format.price, format.percent, format.volume or format.mintick. Left out, the declaration's. | |
precisioninput int | The decimals its values show, up to 16. | |
force_overlayconst bool | false | true draws it on the price pane whatever the declaration says. |
linestyleinput plot_linestyle | plot.linestyle_solid | plot.linestyle_dashed or plot.linestyle_dotted dashes the line. |
plot.style_*
Values for plot's style.
Each is a const plot_style.
| Name | What it means |
|---|---|
plot. | A filled area from histbase. |
plot. | A filled area that breaks at na. |
plot. | A circle at each value. |
plot. | A column from histbase to each value. |
plot. | A cross at each value. |
plot. | A bar from histbase to each value. |
plot. | A line through every value, bridging na. |
plot. | A line that breaks at na. |
plot. | Steps from value to value. |
plot. | Steps with a diamond at each value. |
plot. | Steps that break at na. |
plot.linestyle_*
Values for plot's linestyle.
Each is a string.
| Name | What it means |
|---|---|
plot. | A dashed line. |
plot. | A dotted line. |
plot. | An unbroken line. |
display.*
Values for a plot's display: the places it shows. Each is a whole number with one bit, so they add and subtract: display.all - display.status_line shows everywhere but the legend.
| Name | Type | What it means |
|---|---|---|
display. | const plot_simple_display | Everywhere. |
display. | const plot_display | Listed in the data window. |
display. | const plot_simple_display | Nowhere. The plot isn't drawn, though fill can still use it. |
display. | const plot_display | Drawn in its pane. |
display. | int | Shown in TradingView's Pine Screener. The Screener here doesn't read it, and lists every plot. |
display. | const plot_display | Its last value labelled on the price scale. |
display. | const plot_display | Shown in the legend. |
plotshape
pine
plotshape(series, title, style, location, color, offset, text, textcolor, editable, size, show_last, display, format, precision, force_overlay) → voidDraws a shape on each bar where series is true, or where it isn't na at location.absolute.
| Parameter | Default | Description |
|---|---|---|
seriesseries int/float/bool | When to draw: true, or a value at location.absolute. | |
titleconst string | The shape's name in the legend and the data window. | |
styleinput string | shape.xcross | A shape.* value, such as shape.triangleup, shape.circle or shape.labeldown. |
locationinput string | location.abovebar | location.abovebar, location.belowbar, location.top, location.bottom, or location.absolute to place it at the series' value. |
colorseries color | #2962FF | The shape's colour. A na colour draws nothing on that bar. |
offsetseries int | 0 | Shifts the shapes this many bars. |
textconst string | "" | Text beside the shape. |
textcolorseries color | The text's colour. | |
editableconst bool | true | false leaves it out of the Style settings. |
sizeconst string | size.auto | size.tiny, size.small, size.normal, size.large, size.huge or size.auto. |
show_lastinput int | Draws only the last this-many bars. | |
displayinput plot_display | display.all | Where it shows. |
formatinput string | How its value reads in the data window. | |
precisioninput int | The decimals its value shows. | |
force_overlayconst bool | false | true draws it on the price pane. |
shape.*
Values for plotshape's style.
Each is a const string.
| Name | What it means |
|---|---|
shape. | An arrow pointing down. |
shape. | An arrow pointing up. |
shape. | A circle. |
shape. | A plus sign. |
shape. | A diamond. |
shape. | A flag. |
shape. | A label box with its tail pointing down. |
shape. | A label box with its tail pointing up. |
shape. | A square. |
shape. | A triangle pointing down. |
shape. | A triangle pointing up. |
shape. | An X. |
location.*
Values for plotshape's and plotchar's location: where on each bar the mark goes.
Each is a const string.
| Name | What it means |
|---|---|
location. | Above the bar's high. |
location. | At the value of series, read as a price. |
location. | Below the bar's low. |
location. | At the bottom of the pane. |
location. | At the top of the pane. |
plotchar
pine
plotchar(series, title, char, location, color, offset, text, textcolor, editable, size, show_last, display, format, precision, force_overlay) → voidDraws a character on each bar where series is true, or where it isn't na at location.absolute.
| Parameter | Default | Description |
|---|---|---|
seriesseries int/float/bool | When to draw. | |
titleconst string | Its name in the legend and the data window. | |
charinput string | "★" | The character to draw. |
locationinput string | location.abovebar | Where on the bar, as for plotshape. |
colorseries color | #2962FF | The character's colour. |
offsetseries int | 0 | Shifts the marks this many bars. |
textconst string | "" | Text beside the character. |
textcolorseries color | The text's colour. | |
editableconst bool | true | false leaves it out of the Style settings. |
sizeconst string | size.auto | The character's size. |
show_lastinput int | Draws only the last this-many bars. | |
displayinput plot_display | display.all | Where it shows. |
formatinput string | How its value reads in the data window. | |
precisioninput int | The decimals its value shows. | |
force_overlayconst bool | false | true draws it on the price pane. |
plotarrow
pine
plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, editable, show_last, display, format, precision, force_overlay) → voidDraws an up arrow where series is positive and a down arrow where it is negative, longer the larger the value. Zero and na draw nothing.
| Parameter | Default | Description |
|---|---|---|
seriesseries int/float | The values whose sign picks the arrow. | |
titleconst string | Its name in the legend and the data window. | |
colorupseries color | #00FF00 | The up arrows' colour. |
colordownseries color | #FF0000 | The down arrows' colour. |
offsetseries int | 0 | Shifts the arrows this many bars. |
minheightinput int | 5 | The shortest arrow, in pixels. |
maxheightinput int | 100 | The longest arrow, in pixels. |
editableconst bool | true | false leaves it out of the Style settings. |
show_lastinput int | Draws only the last this-many bars. | |
displayinput plot_display | display.all | Where it shows. |
formatinput string | How its value reads in the data window. | |
precisioninput int | The decimals its value shows. | |
force_overlayconst bool | false | true draws it on the price pane. |
plotcandle
pine
plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display, format, precision, force_overlay) → voidDraws candles from four series of your own. A bar where any of the four is na draws no candle.
| Parameter | Default | Description |
|---|---|---|
openseries int/float | The candles' opens. | |
highseries int/float | The candles' highs. | |
lowseries int/float | The candles' lows. | |
closeseries int/float | The candles' closes. | |
titleconst string | Its name in the legend and the data window. | |
colorseries color | #2962FF | The bodies' colour, fixed or per bar. |
wickcolorseries color | The wicks' colour. | |
editableconst bool | true | false leaves it out of the Style settings. |
show_lastinput int | Draws only the last this-many bars. | |
bordercolorseries color | The bodies' border colour. | |
displayinput plot_display | display.all | Where it shows. |
formatinput string | How its values read. | |
precisioninput int | The decimals its values show. | |
force_overlayconst bool | false | true draws it on the price pane. |
plotbar
pine
plotbar(open, high, low, close, title, color, editable, show_last, display, format, precision, force_overlay) → voidDraws OHLC bars from four series of your own. A bar where any of the four is na draws nothing.
| Parameter | Default | Description |
|---|---|---|
openseries int/float | The bars' opens. | |
highseries int/float | The bars' highs. | |
lowseries int/float | The bars' lows. | |
closeseries int/float | The bars' closes. | |
titleconst string | Its name in the legend and the data window. | |
colorseries color | #2962FF | The bars' colour, fixed or per bar. |
editableconst bool | true | false leaves it out of the Style settings. |
show_lastinput int | Draws only the last this-many bars. | |
displayinput plot_display | display.all | Where it shows. |
formatinput string | How its values read. | |
precisioninput int | The decimals its values show. | |
force_overlayconst bool | false | true draws it on the price pane. |
hline
pine
hline(price, title, color, linestyle, linewidth, editable, display) → hlineDraws a horizontal line across the pane at a fixed price, and returns a reference fill can take. A na price draws nothing.
| Parameter | Default | Description |
|---|---|---|
priceinput int/float | The level. | |
titleconst string | Its name in the settings. | |
colorinput color | #787B86 | The line's colour. |
linestyleinput hline_style | hline.style_dashed | hline.style_solid, hline.style_dotted or hline.style_dashed. |
linewidthinput int | 1 | The line's width in pixels. |
editableconst bool | true | false leaves it out of the Style settings. |
displayinput plot_simple_display | display.all | Without the pane bit, the line starts hidden. |
hline.style_*
Values for hline's linestyle.
Each is a const hline_style.
| Name | Value | What it means |
|---|---|---|
hline. | 2 | A dashed line, the default. |
hline. | 1 | A dotted line. |
hline. | 0 | An unbroken line. |
fill
pine
fill(plot1, plot2, color, title, editable, show_last, fillgaps, display) → void
fill(plot1, plot2, top_value, bottom_value, top_color, bottom_color, title, display, fillgaps, editable) → void
fill(hline1, hline2, color, title, editable, fillgaps, display) → voidColours the space between two plots or two hlines, with one colour per bar or a vertical gradient.
The plain form takes color, worked out per bar. The gradient form takes top_value and bottom_value with top_color and bottom_color, and colours from one to the other between those levels. A na colour leaves that bar's piece empty. A fill on a display with no pane bit draws nothing. When a reference doesn't name a plot or hline, the run warns and nothing is filled.
| Parameter | Default | Description |
|---|---|---|
plot1plot | The first plot. | |
plot2plot | The second plot. | |
colorseries color | The fill's colour, fixed or per bar. Left out, a pale blue. | |
titleconst string | Its name in the settings. | |
editableconst bool | true | false leaves it out of the Style settings. |
show_lastinput int | Fills only the last this-many bars. | |
fillgapsconst bool | false | true bridges bars where a plot is na. |
displayinput plot_simple_display | display.all | Where it shows. |
top_valueseries int/float | The gradient's top level, per bar. | |
bottom_valueseries int/float | The gradient's bottom level, per bar. | |
top_colorseries color | The colour at top_value. | |
bottom_colorseries color | The colour at bottom_value. | |
hline1hline | The first hline, in the hline form. | |
hline2hline | The second hline, in the hline form. |
bgcolor
pine
bgcolor(color, offset, editable, show_last, title, display, force_overlay) → voidColours the background of each bar's whole slot. A na colour leaves that bar's background as it is.
| Parameter | Default | Description |
|---|---|---|
colorseries color | The colour for this bar. | |
offsetseries int | 0 | Shifts the colours this many bars. |
editableconst bool | true | false leaves it out of the Style settings. |
show_lastinput int | Colours only the last this-many bars. | |
titleconst string | Its name in the settings. | |
displayinput plot_simple_display | display.all | Without the pane bit, it starts hidden. |
force_overlayconst bool | false | true colours the price pane. |
barcolor
pine
barcolor(color, offset, editable, show_last, title, display) → voidColours the chart's own candles. A na colour leaves a candle as it is.
The bar still forming takes its colour too, as on TradingView, and offset moves the colour onto another bar. A bar the offset pushes off the chart colours nothing.
| Parameter | Default | Description |
|---|---|---|
colorseries color | The colour for this bar. | |
offsetseries int | 0 | Colours the bar this many bars away instead. |
editableconst bool | true | false leaves it out of the Style settings. |
show_lastinput int | Colours only the last this-many bars. | |
titleconst string | Its name in the settings. | |
displayinput plot_simple_display | display.all | Without the pane bit, nothing is coloured. |