Plotting & Rendering
Declarative plotting primitives, v1.0.6 plot styles (histogram, columns, circles, stepline), variable-assigned plot/hline handles, and gradient cloud fills.
Style Tab Architecture & Registration
Every declarative drawing method (ctx.plot, ctx.hline, ctx.fill, ctx.plotshape, ctx.plotchar, ctx.plotcandle, ctx.plotbar) automatically registers styling schema entries into the indicator's Style Tab.
ctx.plot(dataArray, options) expect their second argument to be an options object (e.g. { title: 'EMA', color: '#2962ff', width: 2, style: 'solid' }). In Direct Pine Mode, both positional and out-of-order keyword arguments (plot(emaVal, color=color.blue, title="EMA")) are reordered and converted automatically.
Sub-Panels vs. Main Chart Overlay (ctx.pane & overlay=false)
By default, custom indicators render on the main candlestick pane. In JS mode set ctx.pane = 'new'; in Direct Pine Mode (v1.0.6), setting indicator("RSI", overlay=false) automatically allocates a dedicated sub-pane when clicked with Run.
// Direct the chart engine to create a new sub-panel at the bottom
ctx.pane = 'new';
const rsi = ctx.ta.rsi(ctx.bars.map(b => b.close), 14);
ctx.plot(rsi, { title: 'RSI', color: '#9c27b0', width: 2 });
ctx.plot(dataArray, options) & Pine plot.style_* (v1.0.6)
Renders line, histogram, column, circle, cross, area, or step series and binds controls to the Style tab. In v1.0.6, you can assign plots to handles (p1 = plot(...)), shift bars with offset, set histbase, and pass per-bar dynamic colors arrays.
| Property | Type | Default | Description |
|---|---|---|---|
| title | string | 'Plot' | Name shown in the Style tab and chart legend. |
| color / colors | string | string[] | '#2196F3' | Base color or per-bar dynamic color array (e.g., close > open ? color.green : color.red). |
| width | number | 1 | Line thickness in pixels (1–4). |
| style | plot.style_* | string | 'solid' | Supports solid/line, dashed, dotted, and Pine v1.0.6 constants: plot.style_linebr, plot.style_stepline, plot.style_histogram, plot.style_columns, plot.style_circles, plot.style_cross, plot.style_area. |
| offset / histbase | number | 0 / 0 | Shifts rendered plot left/right by bars (offset) or anchors histogram/column/area baseline (histbase). |
| trackprice | boolean | false | Shows a horizontal price track line across the chart. |
// Pine histogram with per-bar color and custom baseline
histColor = macdHist >= 0 ? color.teal : color.red
plot(macdHist, title="MACD Hist", style=plot.style_histogram, color=histColor, histbase=0)
// Step line assigned to a handle for fill()
pFast = plot(ta.ema(close, 9), title="Fast EMA", style=plot.style_stepline, color=color.blue)
ctx.hline(priceLevel, options) & Assigned Handles
Plots a static horizontal level across the viewport (ideal for overbought, oversold, and zero lines). Options: { title, color, width, style: 'solid' | 'dashed' | 'dotted' }. In Direct Pine Mode, h1 = hline(70, ...) can be stored in variables and passed directly into fill(h1, h2, ...).
ctx.hline(70, { title: 'Overbought', color: '#f23645', width: 1, style: 'dashed' });
ctx.hline(50, { title: 'Middle Line', color: '#787b86', width: 1, style: 'dotted' });
ctx.hline(30, { title: 'Oversold', color: '#089981', width: 1, style: 'dashed' });
Filling Space Between Plots (ctx.fill / ctx.fill_plots / Pine fill)
Shades the region between two assigned plot handles (p1, p2) or two horizontal levels (h1, h2). v1.0.6 supports solid fills plus gradient fills using top_color, bottom_color, and fillgaps.
// Direct Pine Mode: assigned plot & hline handles
pUpper = plot(ta.highest(high, 20), title="Upper", color=color.blue)
pLower = plot(ta.lowest(low, 20), title="Lower", color=color.orange)
fill(pUpper, pLower, title="Channel Cloud", top_color=color.new(color.blue, 70), bottom_color=color.new(color.orange, 88))
// JavaScript ctx.fill / ctx.fill_plots
ctx.fill(p1, p2, { title: 'BB Cloud', top_color: 'rgba(41,98,255,0.22)', bottom_color: 'rgba(41,98,255,0.04)' });
color.gradient(color1, color2, vertical = true) (v1.0.6)
Creates vertical or horizontal gradient color specifications usable in fills and custom shapes (also documented in Drawings & Colors).
ctx.plotchar(dataArray, options)
Plots indicator glyphs or character signals above or below bars. Options: { char = '*', location = 'belowbar' | 'abovebar' | 'top' | 'bottom' | 'absolute', color = '#FF9800', size = 12, offset = 0 }.
ctx.plotchar(buySignalArray, { char: '▲', location: 'belowbar', color: '#089981', size: 14 });
ctx.plotcandle(open, high, low, close, options) / ctx.plotbar
Renders custom candle bodies and wicks overlaid directly on price columns. Options: { color = '#089981', wickcolor = '#787b86' }.
ctx.plotcandle(openArr, highArr, lowArr, closeArr, { color: '#ffd54f', wickcolor: '#ffb300' });
plotshape(series, title, style, location, color, size)
Plots standard geometric markers (arrows, circles, triangles) matching Pine Script signatures.
plotshape(buyArray, "Buy Signal", shape.triangleup, location.belowbar, color.green, size.small);
barcolor(color) / bgcolor(color)
barcolor dynamically alters candle wick and body colors. bgcolor draws vertical colored background columns behind the chart grid.
barcolor(close > open ? color.green : color.red);
bgcolor(rsi > 70 ? color.new(color.red, 90) : na);