Skip to content

plotbar() - Pine Script Function

plotbar() renders a traditional OHLC bar for each element in the supplied open, high, low, and close series. It is useful when you need to show alternate market sessions, synthetic bars, or higher-timeframe data without switching the main chart period.

Set overlay=true in your indicator() declaration to draw the bars in the price pane. Otherwise, `plotbar()` paints to the script’s separate pane.

plotbar(open, high, low, close, title, color, editable, show_last, display, format, precision, force_overlay) → void
NameTypeDescription
openseries int/floatOpen values for each bar.
highseries int/floatHigh values.
lowseries int/floatLow values.
closeseries int/floatClose values.
titleconst string (optional)Plot name shown in the style dialog.
colorseries color (optional)Bar color. Defaults to bullish/bearish theme colors.
displayinput plot_display (optional)Control where bar information appears (pane, status line, data window, etc.).

Other optional arguments (editable, show_last, format, precision, force_overlay) mirror those provided by plot().

  • If any of the OHLC values are na on a bar, no bar is drawn for that bar.
  • Use plotbar() for transparent overlays by supplying a color with high alpha (color.new(color.green, 80)).
  • Combine with request.security() to fetch and display higher-timeframe data while working on intraday charts.
//@version=5
indicator("Higher-timeframe bar overlay", overlay=true)
htf = input.timeframe("D", "Higher timeframe")
[htfOpen, htfHigh, htfLow, htfClose] =
request.security(syminfo.tickerid, htf, [open, high, low, close])
barColor = htfClose >= htfOpen ? color.new(color.green, 20) : color.new(color.red, 20)
plotbar(htfOpen, htfHigh, htfLow, htfClose,
title="Higher timeframe bars",
color=barColor,
force_overlay=true)