Draws candlesticks from four series for open, high, low and close, with separate colors for body, wick and border.
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
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)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| open | series int/ | required | Series for the candle open. |
| high | series int/ | required | Series for the candle high. |
| low | series int/ | required | Series for the candle low. |
| close | series int/ | required | Series for the candle close. |
| title | const string | "Candles" | Name shown in the legend and Data Window. |
| color | series color | na | Body color, evaluated per bar. |
| wickcolor | series color | same as color | Wick color, evaluated per bar. |
| editable | input bool | true | Accepted for compatibility and ignored. |
| show_last | input int | na | Accepted for compatibility and ignored. |
| bordercolor | series color | same as color | Body border color, evaluated per bar. |
| display | input plot_display | display. | Where the candles are shown. display.none hides them. |
| format | input string | format. | Accepted for compatibility and ignored. |
| precision | input int | na | Accepted for compatibility and ignored. |
| force_overlay | const bool | false | When 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
//@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