Skip to content

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) → plot

Draws 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.

ParameterDefaultDescription
series
series int/float
The values to draw.
title
const string
The plot's name in the legend, the settings and the data window.
color
series color
#2962FFA fixed colour, or one worked out per bar.
linewidth
input int
1The line's width in pixels.
style
input plot_style
plot.style_lineOne of the plot.style_* values below.
trackprice
input bool
falsetrue draws a horizontal line at the last value across the pane.
histbase
input int/float
0The level histograms, columns and areas start from.
offset
series int
0Shifts the plot this many bars right, or left when negative.
join
input bool
falsetrue joins the marks of plot.style_circles and plot.style_cross with a line.
editable
const bool
truefalse leaves the plot out of the Style settings.
show_last
input int
Draws only the last this-many bars.
display
input plot_display
display.allWhere the plot shows: see display.*. Without the pane bit, it isn't drawn.
format
input string
How its values read: format.price, format.percent, format.volume or format.mintick. Left out, the declaration's.
precision
input int
The decimals its values show, up to 16.
force_overlay
const bool
falsetrue draws it on the price pane whatever the declaration says.
linestyle
input plot_linestyle
plot.linestyle_solidplot.linestyle_dashed or plot.linestyle_dotted dashes the line.

plot.style_* ​

Values for plot's style.

Each is a const plot_style.

NameWhat it means
plot.style_areaA filled area from histbase.
plot.style_areabrA filled area that breaks at na.
plot.style_circlesA circle at each value.
plot.style_columnsA column from histbase to each value.
plot.style_crossA cross at each value.
plot.style_histogramA bar from histbase to each value.
plot.style_lineA line through every value, bridging na.
plot.style_linebrA line that breaks at na.
plot.style_steplineSteps from value to value.
plot.style_stepline_diamondSteps with a diamond at each value.
plot.style_steplinebrSteps that break at na.

plot.linestyle_* ​

Values for plot's linestyle.

Each is a string.

NameWhat it means
plot.linestyle_dashedA dashed line.
plot.linestyle_dottedA dotted line.
plot.linestyle_solidAn 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.

NameTypeWhat it means
display.allconst plot_simple_displayEverywhere.
display.data_windowconst plot_displayListed in the data window.
display.noneconst plot_simple_displayNowhere. The plot isn't drawn, though fill can still use it.
display.paneconst plot_displayDrawn in its pane.
display.pine_screenerintShown in TradingView's Pine Screener. The Screener here doesn't read it, and lists every plot.
display.price_scaleconst plot_displayIts last value labelled on the price scale.
display.status_lineconst plot_displayShown in the legend.

plotshape ​

pine
plotshape(series, title, style, location, color, offset, text, textcolor, editable, size, show_last, display, format, precision, force_overlay) → void

Draws a shape on each bar where series is true, or where it isn't na at location.absolute.

ParameterDefaultDescription
series
series int/float/bool
When to draw: true, or a value at location.absolute.
title
const string
The shape's name in the legend and the data window.
style
input string
shape.xcrossA shape.* value, such as shape.triangleup, shape.circle or shape.labeldown.
location
input string
location.abovebarlocation.abovebar, location.belowbar, location.top, location.bottom, or location.absolute to place it at the series' value.
color
series color
#2962FFThe shape's colour. A na colour draws nothing on that bar.
offset
series int
0Shifts the shapes this many bars.
text
const string
""Text beside the shape.
textcolor
series color
The text's colour.
editable
const bool
truefalse leaves it out of the Style settings.
size
const string
size.autosize.tiny, size.small, size.normal, size.large, size.huge or size.auto.
show_last
input int
Draws only the last this-many bars.
display
input plot_display
display.allWhere it shows.
format
input string
How its value reads in the data window.
precision
input int
The decimals its value shows.
force_overlay
const bool
falsetrue draws it on the price pane.

shape.* ​

Values for plotshape's style.

Each is a const string.

NameWhat it means
shape.arrowdownAn arrow pointing down.
shape.arrowupAn arrow pointing up.
shape.circleA circle.
shape.crossA plus sign.
shape.diamondA diamond.
shape.flagA flag.
shape.labeldownA label box with its tail pointing down.
shape.labelupA label box with its tail pointing up.
shape.squareA square.
shape.triangledownA triangle pointing down.
shape.triangleupA triangle pointing up.
shape.xcrossAn X.

location.* ​

Values for plotshape's and plotchar's location: where on each bar the mark goes.

Each is a const string.

NameWhat it means
location.abovebarAbove the bar's high.
location.absoluteAt the value of series, read as a price.
location.belowbarBelow the bar's low.
location.bottomAt the bottom of the pane.
location.topAt 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) → void

Draws a character on each bar where series is true, or where it isn't na at location.absolute.

ParameterDefaultDescription
series
series int/float/bool
When to draw.
title
const string
Its name in the legend and the data window.
char
input string
"★"The character to draw.
location
input string
location.abovebarWhere on the bar, as for plotshape.
color
series color
#2962FFThe character's colour.
offset
series int
0Shifts the marks this many bars.
text
const string
""Text beside the character.
textcolor
series color
The text's colour.
editable
const bool
truefalse leaves it out of the Style settings.
size
const string
size.autoThe character's size.
show_last
input int
Draws only the last this-many bars.
display
input plot_display
display.allWhere it shows.
format
input string
How its value reads in the data window.
precision
input int
The decimals its value shows.
force_overlay
const bool
falsetrue draws it on the price pane.

plotarrow ​

pine
plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, editable, show_last, display, format, precision, force_overlay) → void

Draws 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.

ParameterDefaultDescription
series
series int/float
The values whose sign picks the arrow.
title
const string
Its name in the legend and the data window.
colorup
series color
#00FF00The up arrows' colour.
colordown
series color
#FF0000The down arrows' colour.
offset
series int
0Shifts the arrows this many bars.
minheight
input int
5The shortest arrow, in pixels.
maxheight
input int
100The longest arrow, in pixels.
editable
const bool
truefalse leaves it out of the Style settings.
show_last
input int
Draws only the last this-many bars.
display
input plot_display
display.allWhere it shows.
format
input string
How its value reads in the data window.
precision
input int
The decimals its value shows.
force_overlay
const bool
falsetrue 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) → void

Draws candles from four series of your own. A bar where any of the four is na draws no candle.

ParameterDefaultDescription
open
series int/float
The candles' opens.
high
series int/float
The candles' highs.
low
series int/float
The candles' lows.
close
series int/float
The candles' closes.
title
const string
Its name in the legend and the data window.
color
series color
#2962FFThe bodies' colour, fixed or per bar.
wickcolor
series color
The wicks' colour.
editable
const bool
truefalse leaves it out of the Style settings.
show_last
input int
Draws only the last this-many bars.
bordercolor
series color
The bodies' border colour.
display
input plot_display
display.allWhere it shows.
format
input string
How its values read.
precision
input int
The decimals its values show.
force_overlay
const bool
falsetrue draws it on the price pane.

plotbar ​

pine
plotbar(open, high, low, close, title, color, editable, show_last, display, format, precision, force_overlay) → void

Draws OHLC bars from four series of your own. A bar where any of the four is na draws nothing.

ParameterDefaultDescription
open
series int/float
The bars' opens.
high
series int/float
The bars' highs.
low
series int/float
The bars' lows.
close
series int/float
The bars' closes.
title
const string
Its name in the legend and the data window.
color
series color
#2962FFThe bars' colour, fixed or per bar.
editable
const bool
truefalse leaves it out of the Style settings.
show_last
input int
Draws only the last this-many bars.
display
input plot_display
display.allWhere it shows.
format
input string
How its values read.
precision
input int
The decimals its values show.
force_overlay
const bool
falsetrue draws it on the price pane.

hline ​

pine
hline(price, title, color, linestyle, linewidth, editable, display) → hline

Draws a horizontal line across the pane at a fixed price, and returns a reference fill can take. A na price draws nothing.

ParameterDefaultDescription
price
input int/float
The level.
title
const string
Its name in the settings.
color
input color
#787B86The line's colour.
linestyle
input hline_style
hline.style_dashedhline.style_solid, hline.style_dotted or hline.style_dashed.
linewidth
input int
1The line's width in pixels.
editable
const bool
truefalse leaves it out of the Style settings.
display
input plot_simple_display
display.allWithout the pane bit, the line starts hidden.

hline.style_* ​

Values for hline's linestyle.

Each is a const hline_style.

NameValueWhat it means
hline.style_dashed2A dashed line, the default.
hline.style_dotted1A dotted line.
hline.style_solid0An 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) → void

Colours 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.

ParameterDefaultDescription
plot1
plot
The first plot.
plot2
plot
The second plot.
color
series color
The fill's colour, fixed or per bar. Left out, a pale blue.
title
const string
Its name in the settings.
editable
const bool
truefalse leaves it out of the Style settings.
show_last
input int
Fills only the last this-many bars.
fillgaps
const bool
falsetrue bridges bars where a plot is na.
display
input plot_simple_display
display.allWhere it shows.
top_value
series int/float
The gradient's top level, per bar.
bottom_value
series int/float
The gradient's bottom level, per bar.
top_color
series color
The colour at top_value.
bottom_color
series color
The colour at bottom_value.
hline1
hline
The first hline, in the hline form.
hline2
hline
The second hline, in the hline form.

bgcolor ​

pine
bgcolor(color, offset, editable, show_last, title, display, force_overlay) → void

Colours the background of each bar's whole slot. A na colour leaves that bar's background as it is.

ParameterDefaultDescription
color
series color
The colour for this bar.
offset
series int
0Shifts the colours this many bars.
editable
const bool
truefalse leaves it out of the Style settings.
show_last
input int
Colours only the last this-many bars.
title
const string
Its name in the settings.
display
input plot_simple_display
display.allWithout the pane bit, it starts hidden.
force_overlay
const bool
falsetrue colours the price pane.

barcolor ​

pine
barcolor(color, offset, editable, show_last, title, display) → void

Colours 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.

ParameterDefaultDescription
color
series color
The colour for this bar.
offset
series int
0Colours the bar this many bars away instead.
editable
const bool
truefalse leaves it out of the Style settings.
show_last
input int
Colours only the last this-many bars.
title
const string
Its name in the settings.
display
input plot_simple_display
display.allWithout the pane bit, nothing is coloured.

See also ​

AmenoScript is compatible with Pine Script v6. Pine Script is a trademark of TradingView, Inc., which has no part in AmenoScript.