Heat maps and profiles
Beyond plots, shapes and boxes, a script can draw a time-by-price heat map behind the candles, a volume or value-area profile with its point of control, and its own pixel drawings. Your script hands over the numbers; the chart does the drawing, so these stay fast while you pan and zoom.
draw.heatmap(cells, opts?)A time-by-price grid drawn behind the candles. cells: { bar?, price, value } (bar counts back from the current bar, default 0), or a matrix { priceFrom, bucket, columns: [{ bar?, values }] }. Cells of the same bar and bucket add up; calls with the same name merge. opts: name, bucket (price height of a cell), colors (2 or 3 stops, low to high), opacity, min, max, scale (linear, sqrt or log). Up to 200,000 cells per script.
draw.heatmap(cells, { bucket: 10, scale: 'sqrt', colors: ['#0b1f4d', '#00bcd4', '#ffeb3b'] });draw.profile(levels, opts?)A horizontal histogram by price with the point of control and the value area. levels: { price, value?, buy?, sell? }; buy and sell split each row in two colours. Docked to the right edge of the pane, or anchored to bars with opts.from / opts.to (bars back). opts: name, bucket, width (% of the pane, or of the bar range), valueArea (default 0.7), showPoc, showValueArea, color, buyColor, sellColor, pocColor, valueAreaColor, opacity. Up to 2,000 rows per script.
draw.profile(rows, { name: 'Session', from: 23, to: 0, width: 70 });draw.pixel({ name, draw })Your own drawing in pane pixels: draw(ctx, bounds, bars) gets a canvas-like ctx (fillRect, strokeRect, paths, arc, fillText, fillStyle, font...) that records up to 5,000 calls. It runs in the sandbox after every update and again when the pane is resized.
draw.pixel({ name: 'Badge', draw: (ctx, b) => { ctx.fillStyle = '#2962ff'; ctx.fillRect(b.width - 90, 10, 80, 20); } });Where they runBoth script forms: an indicator() body, or the onBar() of a class-form Lab (bar then counts back from the bar being processed). They redraw on every update, follow pan and zoom, and go away with the script. Backtests and scans skip them.
Two ready-made examples are in the Template Library under Microstructure: Liquidity heatmap from order book and Session volume profile.