"Pine Script plot arguments: trackprice, show_last, hline style, plotchar and plotarrow"
The drawing arguments of plot, hline, plotchar, plotarrow, plotcandle and table.cell in Pine Script v6, with a working example of each and how SuperCharting draws them.
Pine's plotting functions take more than a value and a colour. This page covers the arguments that change how a plot looks: trackprice and show_last on plot(), the style and width of hline(), the character of plotchar(), the height of plotarrow(), the wick and border colours of plotcandle(), and the size and alignment of table cells. SuperCharting draws all of them in Pine Script v5 and v6.
plot(): trackprice and show_last
//@version=6
indicator("SMA with track line", overlay = true)
plot(ta.sma(close, 20), "SMA 20", color.blue, trackprice = true, show_last = 50)
trackprice = truedraws a dotted horizontal line across the pane at the plot's latest value, with its price on the scale.show_last = 50draws only the last 50 bars of the plot. The values still exist for alerts and the data window.
show_last and display also work on plotshape(), plotchar(), plotarrow() and bgcolor(). display = display.none hides a visual and keeps its values.
hline(): line style and width
//@version=6
indicator("RSI levels")
plot(ta.rsi(close, 14), "RSI", color.purple)
hline(70, "Overbought", color.red, linestyle = hline.style_solid, linewidth = 2)
hline(50, "Middle", color.gray, linestyle = hline.style_dotted)
hline(30, "Oversold", color.green, linestyle = hline.style_dashed, linewidth = 2)
The default is a dashed line, width 1, as in Pine.
plotchar(): any character
//@version=6
indicator("Up days", overlay = true)
plotchar(close > open, "Up", char = "▲", location = location.belowbar,
color = color.green, size = size.small, text = "up", textcolor = color.gray)
char takes one character, including symbols and emoji. size sets its size (size.tiny to size.huge), and text is written next to it in textcolor.
plotarrow(): arrow height
//@version=6
indicator("Momentum arrows", overlay = true)
plotarrow(close - close[1], "Change", minheight = 10, maxheight = 60)
A positive value draws an up arrow under the bar and a negative one a down arrow above it. The arrow's length grows with the size of the value, from minheight to maxheight pixels.
plotcandle() and plotbar()
//@version=6
indicator("Heikin Ashi candles")
ha_c = (open + high + low + close) / 4
ha_o = float(na)
ha_o := na(ha_o[1]) ? (open + close) / 2 : (ha_o[1] + ha_c[1]) / 2
plotcandle(ha_o, math.max(high, ha_o), math.min(low, ha_o), ha_c, "HA",
color = ha_c >= ha_o ? color.teal : color.red, wickcolor = color.gray, bordercolor = color.black)
wickcolor and bordercolor colour the wicks and the body outline. plotbar() draws the same four values as OHLC bars.
table.cell(): size and alignment
//@version=6
indicator("Info table", overlay = true)
var t = table.new(position.top_right, 2, 1, border_color = color.gray, border_width = 1)
if barstate.islast
table.cell(t, 0, 0, "Close", width = 10, text_halign = text.align_left)
table.cell(t, 1, 0, str.tostring(close), text_halign = text.align_right, text_size = size.large)
width and height are a percentage of the chart, text_halign and text_valign place the text inside the cell, and text_size and text_font_family set the font. A \n in the text starts a new line.
How to try it
Open the Pine Editor at the bottom of a chart, paste any example above and click Add to chart. The free Pine Script checker checks a script without an account.
Frequently asked questions
Why does show_last not change my alerts?
show_last only hides older bars on the chart. Alerts and the data window still read every value.
Can hline be drawn on the price chart from a pane indicator?
No, hline() stays in its own pane. Use plot() with a constant value and force_overlay = true, as shown in the force_overlay guide.