Getting Started

PineCanvas

An open-source graphics engine for TradingView, written in Pine Script v6. It draws heatmaps, detailed images, rasterized 3D frames, and tens of thousands of filled shapes inside Pine's drawing limits.

Updated Publisher Alien_AlgorithmsPine Script v6
TradingView Library
PineCanvas: A Native High-Resolution Graphics Engine
Open the published PineCanvas library, read its source, and add it to your Pine Script workflow.

What is PineCanvas?

PineCanvas is a contour rendering engine for TradingView. You describe a picture as a grid of cells or as a queue of filled shapes, and the library turns it into chart drawings. It handles contour tracing, colour quantization, polyline packing, drawing budgets, and caching.

Each cell acts like a pixel in the source image. Around 1.1 million cells in one image is an attainable scale: the published Julia fractal below is 1344 × 804 cells, which is 1,080,576.

A Julia fractal of over one million cells drawn on a TradingView chart with PineCanvas
TradingView capture. A Julia fractal at 1344 × 804 cells, drawn natively by a Pine Script that imports PineCanvas.
Built around Pine drawing limits
Pine Script allows 500 boxes and 100 polylines per script. One box per cell runs out at just 20 × 25 cells. PineCanvas draws the boundaries of same-colour regions instead, so resolution is no longer tied to the number of drawings.

How contour rendering works

  • Every cell is mapped to a colour level: an exact palette index, or a value quantized through a gradient.
  • Cells of one colour that touch form a region.
  • Each region is traced as an outline, and its internal edges are discarded. A solid block of thousands of cells is described by its four outer corners.
  • Separate regions of one colour are joined through invisible, zero-width links, so they share a polyline.
  • A polyline holds up to 10,000 points, and a script may draw 100 of them.
  • Transparent cells produce no geometry at all. Holes and empty space stay unfilled.

The practical limit of a picture is therefore its boundary complexity and its number of colours, not a fixed pixel count. Smooth or sparse images can go beyond a million cells. Highly fragmented ones can be demanding at much smaller sizes.

A chainable API

A source, a Canvas, one draw callpine
var pc.ValueField levels = pc.valueField(240, 400)
var pc.Canvas heat = pc.heatmap()
  .colorLevels(48)
  .opacity(10, 90)
  .gamma(0.7)

if barstate.islast
    heat.drawLookback(levels, 0, bottomPrice, topPrice)

A source holds the data. A Canvas holds the colours and the style, and owns the drawings it creates. Every Canvas setter returns the Canvas, so configuration reads as one chain.

What you can build

Heatmaps
Numbers placed across time and price, with 2 to 100 colour levels, opacity ramps, gamma, and stable or automatic scaling.
Images
Exact-colour pictures of up to 100 palette entries, with transparent cells and precise edges.
Pine3D frames
Rasterized 3D scenes with depth-tested visibility, smooth shading, and cast shadows.
Filled shapes
Rectangles, triangles, ellipses, and polygons in chart time and price, packed by colour.
Rolling sources
Moving windows that take one new column per bar without shifting their history.
Layers
Several canvases in one script, each with its own share of the polyline budget.

Where to go next

PineCanvas is created by Alien_Algorithms. Import the published library with Alien_Algorithms/PineCanvas/1, and see it in motion on the PineCanvas product page.

PineCanvas is a graphics library for Pine Script. TradingView drawing, memory, and execution limits still apply. © Alien_Algorithms.