plotcandle() - Pine Script Function
plotcandle()
Section titled “plotcandle()”Overview
Section titled “Overview”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.
Syntax
Section titled “Syntax”plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display, format, precision, force_overlay) → voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
open | series int/float | Open values for each candle. |
high | series int/float | High values. |
low | series int/float | Low values. |
close | series int/float | Close values. |
color | series color (optional) | Fill color for the candle body. Defaults to bullish/bearish theme colors. |
wickcolor | series color (optional) | Wick color. |
bordercolor | series color (optional) | Outline color around the candle body. |
display | input 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().
Remarks
Section titled “Remarks”- 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.
Example
Section titled “Example”//@version=5indicator("Heikin-Ashi overlay", overlay=true)
haClose = (open + high + low + close) / 4.0var float haOpen = nahaOpen := na(haOpen[1]) ? (open + close) / 2.0 : (haOpen[1] + nz(haClose[1], close)) / 2.0haHigh = 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)