Reference

Common Pitfalls

Diagnose empty panes, pictures in the wrong place, colours that shift, drawings that disappear, and the runtime errors a render can raise.

Updated Publisher Alien_AlgorithmsPine Script v6

Nothing appears

CauseFix
Every cell is transparent.A new field starts at na or -1. Check that the cells are actually written before the draw call.
The draw call never runs.Its guard is too strict, for example a bar_index check larger than the chart's history. Load more bars or reduce the columns.
A rolling source has fewer than two columns.A scroll draws nothing until two columns were pushed. Check that push() runs on confirmed bars.
The opacity is 0.A level with no opacity is not drawn. With opacity(0, 100) the weakest level is invisible by design.
Every value sits below the range.With valueRange(), values at or under the minimum take the lowest level, which a heatmap preset draws faintly. Check the bounds against the data.
The picture is outside the visible scale.In a separate pane, add invisible plots at the vertical bounds. On the price chart, the bounds must be prices.

Wrong place or orientation

The picture is upside down

Row 0 is the bottom row. Write the picture bottom-up, or call invertRows() on the Canvas.

The picture is mirrored in time

Column 0 is the oldest bar and the last column is the newest. When reading history with an offset, the offset for a column is columns - 1 - column.

A heatmap does not line up with price

The script must draw on the price chart, through overlay = true or forceOverlay(), and bottom and top must be the prices the first and last row cover. On a log-scaled chart, set logarithmicY() as well.

Cells sit between candles

A column spans from one bar to the next. That is how a grid placed on bar positions divides the time axis, and it is the same for every column.

Colour problems

SymptomExplanation
Colours change from bar to bar.Automatic scaling follows the data. Use valueRange() to keep a colour tied to a value.
A value field shows only two colours.newCanvas() starts with one level per colour given. Add colorLevels().
Weak values are invisible.Lower gamma() below 1, or raise the first argument of opacity().
The gradient looks banded.Raise colorLevels(). More levels cost more geometry.
Overlapping shapes do not darken.Same-colour shapes in one batch form a union. Use a second colour or a second Canvas.

Missing or replaced drawings

SymptomCauseFix
Shapes vanish when the field draws.Both were drawn by one Canvas, and each draw replaces the last.Use one Canvas per layer.
An older layer disappears.The script went past 100 polylines and TradingView removed the oldest.Give each Canvas a drawingLimit() share and watch polyline.all.size().
Only part of the script draws.max_polylines_count was left at its default.Set max_polylines_count = 100 in the declaration.
Your own polylines disappear.They share the same pool as every Canvas.Count them in the budget.

Runtime errors

PineCanvas validates its input and stops the script with a short message when something cannot be drawn.

MessageMeaning
lookback must be 0 or >=columnsdrawLookback() was given a lookback smaller than the field's column count.
bar index is negativeThe left edge is before the first bar. Wait for more bars or draw fewer columns.
X is >10000 bars back; use timeThe left edge is more than 10,000 bars back. Use drawTime().
X is >500 future barsThe right edge is more than 500 bars ahead of the current bar.
X span must be >=columnsdraw() was given fewer bars than the field has columns.
yMax must exceed yMintop is not greater than bottom.
log Y requires yMin>0logarithmicY() is on and bottom is zero or negative.
need N drawings, above this Canvas's drawingLimit.The picture needs more polylines than its Canvas may use. Use fewer colours or less detail, or raise drawingLimit().
index must be -1 or 0..N.A palette field holds an index outside the palette.
palettes needs 2..100 colorsA palette or gradient has fewer than 2 or more than 100 colours.
colorLevels must be 2..100A style value is out of range. The same form is used for opacity, gamma, and drawingLimit.
valueRange requires max>minvalueRange() was given a maximum that is not above the minimum.
push size must equal scroll rowsThe array given to push() does not have exactly rows values.
field cell out of boundsA row or column passed to get() or set() is outside the field.
shape corners need from_time()A shape point was not created with chart.point.from_time().
shape queue >100000 verticesToo many vertices were queued before drawShapes().
shape colors exceed 100The queued shapes use more than 100 distinct fill colours.
shapes exceed drawingLimitThe queued shapes need more polylines than the Canvas may use.
Canvas is na; use newCanvas()A method was called on a Canvas variable that was never assigned.
Codes such as E7
A message that is only a short code marks an internal consistency check that valid input should never reach. If you see one, note the field size and style that produced it and report it on the TradingView publication.

Timeouts

A loop that runs longer than 500 milliseconds on one bar stops the script. Find out first whether the time goes into your own loops or into the render, using the Pine Profiler. Then lower the colour levels, add a transparent floor, and spread the filling of the source across bars. Performance & Large Images walks through each step.

Chart behaviour

Thin seams between fills

The chart's anti-aliasing can show hairline seams between adjacent fills at some zoom levels. They come from how the chart rasterizes neighbouring polygons, and they change or vanish as the zoom changes.

Animation follows executions

A picture updates when the script runs, which is on each new tick or bar. There is no separate timer, so a market that is closed does not animate.

The picture appears only after loading

A render guarded by barstate.islast or barstate.islastconfirmedhistory runs when the chart has processed its history. That is intended: rendering on every historical bar would repeat the work thousands of times.

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