Skip to content

plot() - Pine Script Function

plot() is Pine Script’s primary drawing primitive. It renders one series of values in the script’s pane using styles ranging from simple lines to histograms, columns, or areas. The function returns a plot handle you can reference later (e.g., when calling fill()).

Every script can draw a limited number of plots (default 64). Reuse existing handles or disable unnecessary plots (e.g., with the display argument) to stay under the limit.

plot(series, title, color, linewidth, style, trackprice, histbase, offset, join, editable, show_last, display, format, precision, force_overlay, linestyle) → plot
NameTypeDescription
seriesseries int/floatValues to draw. Must be a series expression.
titleconst string (optional)Label shown in the legend and style dialogs. Defaults to "plot".
colorseries color (optional)Line or column color. Accepts static or dynamic colors.
linewidthinput int (optional)Stroke width in pixels (1–5).
styleinput plot.style (optional)Render mode (e.g., plot.style_line, plot.style_histogram, plot.style_area). Defaults to plot.style_line.
trackpriceconst bool (optional)Draws a price marker at the latest value when true.
histbaseseries int/float (optional)Baseline for histogram/area styles. Defaults to 0.
offsetsimple int (optional)Shifts the plot left/right by bars (positive values look forward).
displayinput plot_display (optional)Controls where the plot appears (pane, data window, price scale, etc.).
formatinput format (optional)Overrides the script’s default number formatting.
precisioninput int (optional)Digits after the decimal (0–16). Ignored for format.volume.

Other parameters (join, editable, show_last, force_overlay, linestyle) are optional quality-of-life toggles. See the official reference for full details.

plot — Handle representing the drawn series.

  • Passing na hides the plot on that bar. Use plot(series, ..., display=display.none) to keep the handle without rendering.
  • Change colors dynamically by supplying ternary expressions or palette arrays to the color parameter.
  • When combining multiple plots, capture their handles (var pFast = plot(...)) so you can reference them once per bar without redrawing.
//@version=5
indicator("plot() styles demo", overlay=false, max_lines_count=1)
fast = ta.ema(close, 21)
slow = ta.ema(close, 55)
plot(close, "Close histogram",
style=plot.style_histogram,
color=color.new(color.gray, 70),
linewidth=2)
fastPlot = plot(fast, "Fast EMA", color=color.teal, linewidth=2)
slowPlot = plot(slow, "Slow EMA", color=color.orange, linewidth=2)
fill(fastPlot, slowPlot,
title="EMA spread fill",
color=fast > slow ? color.new(color.green, 85) : color.new(color.red, 85))