Sidechair

plotcandle()

Browse the reference

Draws candlesticks from four series for open, high, low and close, with separate colors for body, wick and border.

Try it in the editor

plotcandle draws a candle on each bar from the four values you pass, in open, high, low, close order. It does not need to match the chart's own prices, so you can plot smoothed candles or another symbol's bars.

color fills the body, wickcolor colors the wick and bordercolor outlines the body. Where wickcolor or bordercolor is left out, the body color is used. Any na among the four values skips that bar.

Syntax

Pine Script
plotcandle(open: series int/float, high: series int/float, low: series int/float, close: series int/float, title: const string (optional), color: series color (optional), wickcolor: series color (optional), editable: input bool (optional), show_last: input int (optional), bordercolor: series color (optional), display: input plot_display (optional), format: input string (optional), precision: input int (optional), force_overlay: const bool (optional)) -> void

Arguments

NameTypeDefaultDescription
openseries int/floatrequiredSeries for the candle open.
highseries int/floatrequiredSeries for the candle high.
lowseries int/floatrequiredSeries for the candle low.
closeseries int/floatrequiredSeries for the candle close.
titleconst string"Candles"Name shown in the legend and Data Window.
colorseries colornaBody color, evaluated per bar.
wickcolorseries colorsame as colorWick color, evaluated per bar.
editableinput booltrueAccepted for compatibility and ignored.
show_lastinput intnaAccepted for compatibility and ignored.
bordercolorseries colorsame as colorBody border color, evaluated per bar.
displayinput plot_displaydisplay.allWhere the candles are shown. display.none hides them.
formatinput stringformat.inheritAccepted for compatibility and ignored.
precisioninput intnaAccepted for compatibility and ignored.
force_overlayconst boolfalseWhen true, draws on the main chart pane even if the script runs in its own pane.

Returns

Nothing.

Remarks

  • To replace the chart's candles with a custom set, plot with overlay = true and hide the chart's own series.
  • On Sidechair: the color argument has no default; pass one, for example close >= open ? color.green : color.red, to make the candles visible.

Example

Pine ScriptHeikin-Ashi style smoothingOpen in editor
//@version=6
indicator("Smoothed candles", overlay = true)
haClose = (open + high + low + close) / 4
float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh = math.max(high, haOpen, haClose)
haLow = math.min(low, haOpen, haClose)
plotcandle(haOpen, haHigh, haLow, haClose, "HA", haClose >= haOpen ? color.teal : color.maroon)

See also

Runs on Sidechair