Errors and recalculation
Where errors show up, when the indicator recalculates and what the limits are.
Two kinds of error
| Error | Examples | Where it shows |
|---|---|---|
| Compile error | Syntax, a construct that isn’t allowed, a name that doesn’t exist, a wrong argument in a declaration | In the editor, on the line, and in the console |
| During the calculation | A division by zero, an index out of the list, a raise ValueError | In the Log tab, with the line; in the legend only “Script error”: the indicator doesn’t draw |
Compile errors show up when you save: the compiler checks the whole script, even the lines that wouldn’t run. The messages are in Italian and say what was expected, like Nelle dichiarazioni si scrivono solo valori, non calcoli or Le candele non hanno il campo closes.
if length < 2:
raise ValueError("Length must be at least 2")With raise ValueError(…) you stop the calculation with your own message, which appears in the legend.
When it recalculates
- When data or settings change: a new or updated candle, a page of history, a new news event or data just released, an input, the chart’s timeframe. Never when scrolling or zooming.
- Each calculation redoes everything, from the first candle: that’s why the function receives the whole series. In real time each tick restarts the calculation, and the indicator lags by at most one calculation.
- While data is arriving, candles or news, the legend shows a spinning circle and the previous values remain.
Timed out
A full calculation has 5 seconds: beyond that, it stops with “Timed out”, and the other indicators carry on. Once stopped it doesn’t download more data, not even when you move the chart: “Reload” in the legend’s More menu restarts it, after the other errors too. If the calculation is slow, reduce the candles with max_bars or avoid loops inside loops over all candles.
Limits
| Limit | Value |
|---|---|
| Code size | 200 KB |
| Name of a script or a publication | 40 characters |
| Description of a publication | 500 characters |
| Inputs | 32 |
| Plots | 32 |
| Drawings per indicator | 500, up to 10,000 with max_drawings |
| Candles after the latest, for drawing points | 500 |
| print lines per calculation | 1000 |
| Distinct requests, request.bars and request.events | 8 |
| Candles per calculation, for each request | 200,000 if max_bars is missing |
| Time for a full calculation | 5 seconds |