TradingCharts

Bar Plotting

Two declarative calls render *synthetic candles* from your own OHLC series:

plotcandle()

plotcandle(open, high, low, close, title?, color?, wickcolor?, bordercolor?,
           editable?, show_last?, display?, force_overlay?)

Heikin-Ashi example:

haClose = (open + high + low + close) / 4
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh  = math.max(high, math.max(haOpen, haClose))
haLow   = math.min(low,  math.min(haOpen, haClose))

bull = haClose >= haOpen
plotcandle(haOpen, haHigh, haLow, haClose, "Heikin-Ashi",
           color      = bull ? color.lime : color.red,
           wickcolor  = bull ? color.lime : color.red,
           bordercolor= bull ? color.lime : color.red)
  • color paints the candle body (and the fill, if hollow).
  • wickcolor and bordercolor paint the wick and the body outline. If omitted they default to color.

plotbar()

plotbar(open, high, low, close, title?, color?, editable?, show_last?, display?)

OHLC bars share the single color argument for the vertical line and the open/close ticks:

plotbar(open, high, low, close, "Bars",
        color = close > open ? color.lime : color.red)

Volume example — multi-colour columns

Pair plotcandle with color for shaded body plus wick:

plotcandle(math.min(open, close), high, low, math.max(open, close),
           "Wick-less body",
           color = close > open ? color.lime : color.red,
           wickcolor = color.gray, bordercolor = color.gray)

Z-order

Synthetic candles always render on the price pane. In an overlay = false script they draw in their own pane along with the oscillator; force_overlay = true moves them to the price pane.

See also

  • Plots — style_histogram and style_columns for simpler bar-like plots
  • Colors
  • Bar coloring — recolour the chart's own candles instead