Skip to main content
plot draws one value per bar. Its relatives mark bars (plotshape, plotchar, plotarrow), draw candles or bars of your own (plotcandle, plotbar) or draw a level (hline). For anything that is not one value on every bar, see Plots or drawings.

Top level only

Every one of these calls, and fill, bgcolor, barcolor and alertcondition, must stand at the top level of the script: not in an if, a loop, a switch or a function of yours. The editor refuses it:
The compiler says: plot() must be called in the global scope. Put the condition in the arguments instead. A plotted na leaves a gap, and a na color draws nothing:

plot

plot(series, title, color, linewidth, style, trackprice, histbase, offset, force_overlay, display, format). Only series is required. A computed linewidth is refused (An argument of series inttype was used but ainput int is expected.). To vary a plot’s look by bar, vary its color, or plot twice with different arguments.
plot returns a plot value that fill accepts.

Where a plot is shown: display and format

display takes display.none, pane, data_window, price_scale, status_line or all (the default); add constants with +: display=display.pane + display.price_scale. It is an argument of every call on this page and of fill, bgcolor, barcolor and the inputs; the terminal decides what each place shows. fill, barcolor and bgcolor take only display.none and display.all (see Fills and levels). format on plot, plotshape, plotchar, plotarrow and hline takes format.price, format.percent or format.volume. The editor accepts format.mintick and format.inherit; adding the script to the chart refuses them:
The compiler says (when added to the chart): The format argument only accepts format.price, format.percent, or format.volume. Got format.mintick.

Marks on bars

  • plotshape(series, title, shape, location, color, offset, text, textcolor, size, force_overlay, display, format) draws a shape on each bar where the bool series is true. shape is shape.xcross, cross, triangleup, triangledown, flag, circle, arrowup, arrowdown, labelup, labeldown, square or diamond; location is location.abovebar, belowbar, top, bottom or absolute; size is size.auto, tiny, small, normal, large or huge. Given a float series instead, it draws at that price, and a na draws nothing.
  • plotchar is the same with char, one character (const string) instead of shape; a longer string is cut to its first character.
  • plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, force_overlay, display, format) draws an arrow up for a positive value and down for a negative one, sized by the value.
  • text is a const string; see Text and markers.

Your own bars and a level

plotcandle(open, high, low, close, title, color, wickcolor, bordercolor, force_overlay, display) and plotbar(open, high, low, close, title, color, display, force_overlay) draw bars from four series; all four are required. hline(price, title, color, linewidth, style, display, format) draws a horizontal line; price is an input value (see Fills and levels): plotcandle(talib.sma(open, 3), talib.sma(high, 3), talib.sma(low, 3), talib.sma(close, 3)).