Skip to content

plotcandle() - Pine Script Function

plotcandle() plots traditional candlesticks built from custom OHLC data. You can repaint the current chart with alternative pricing sources, display higher-timeframe candles, or overlay derived candle families such as Heikin-Ashi or Renko.

Enable overlay=true in your script declaration to draw the candles on top of the base chart. Otherwise the candles appear in a separate indicator pane.

plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display, format, precision, force_overlay) → void
NameTypeDescription
openseries int/floatOpen values for each candle.
highseries int/floatHigh values.
lowseries int/floatLow values.
closeseries int/floatClose values.
colorseries color (optional)Fill color for the candle body. Defaults to bullish/bearish theme colors.
wickcolorseries color (optional)Wick color.
bordercolorseries color (optional)Outline color around the candle body.
displayinput plot_display (optional)Choose where candle data appears (pane, status line, data window, etc.).

The remaining arguments (title, editable, show_last, format, precision, force_overlay) mirror those in plot().

  • If any OHLC component is na, that candle is skipped.
  • Supply semi-transparent colors (color.new(color.green, 60)) to view underlying price bars through the overlay.
  • Pair with request.security() or computed series to draw transformed candles while keeping the main chart timeframe intact.
//@version=5
indicator("Heikin-Ashi overlay", overlay=true)
haClose = (open + high + low + close) / 4.0
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2.0 : (haOpen[1] + nz(haClose[1], close)) / 2.0
haHigh = math.max(high, math.max(haOpen, haClose))
haLow = math.min(low, math.min(haOpen, haClose))
bodyColor = haClose >= haOpen ? color.new(color.green, 10) : color.new(color.red, 10)
wickColor = color.new(color.gray, 30)
borderColor = color.new(color.black, 40)
plotcandle(haOpen, haHigh, haLow, haClose,
title="Heikin-Ashi candles",
color=bodyColor,
wickcolor=wickColor,
bordercolor=borderColor,
force_overlay=true)