It Drew 238 Lines and the CSV Is Empty: What 366 Drawing-Only Pine Scripts Taught Me
Your Pine script draws 238 lines, 486 labels, 360 boxes. The Python port runs without errors. The output file is 0 bytes. The drawings are not missing — they are in a different place than you looked.
This is the seventh post in a series where I convert Pine strategies to Python line by line. The last post was about 196 scripts that ran fine and produced nothing. This one is about the 366 scripts that produce something — just not the kind of something a CSV can hold.
The headline numbers first, because this is the part you can check:
| Script | Objects created | Live at end | What the run CSV holds |
|---|---|---|---|
| Pivot lines | 238 lines | 50 | 0 bytes |
| Pivot labels | 486 labels | 50 | 0 bytes |
| Gap boxes | 360 boxes | 50 | 0 bytes |
| Dashboard table | 1 table, 4,087 cell updates | 1 | 0 bytes |
| One updating ray | 238 lines, 3,808 updates | 1 | 0 bytes |
Control: same feed, one plot()
|
— | — | 4,089 rows (post #6) |
The honest number is 0. Five scripts, five kinds of drawing, the same measured result: the standard output file is empty. The rest of this post is where the output actually went — and the checklist I now run before I ever say a drawing-only port "produced nothing."
How we tested
- Feed: 4,089 bars of CSI 300 daily data, 2010-01-04 to 2026-11-06, same feed as posts #4–#6.
- Compiler: the local compiler (
node bin/pine2pyne.mjs), zero diagnostics on all five scripts — nothing unsupported, nothing dropped. - Runner: the open-source PyneCore runtime (6.10.12), with its drawing journal switched on, so every create, update, and delete of every drawing object is recorded bar by bar.
- No tuning, no picking the good cases afterwards: the five scripts below are the five drawing types Pine has — line, label, box, table, and the one-line update idiom — each in its smallest realistic form.
- Every count in this post comes from the journal and the final drawing registries, and every count was cross-checked against an independent pandas calculation on the same feed.
First, what "drawing-only" means — and what it doesn't
The corpus numbers come from the sweep I reported in post #3: 1,909 real Pine scripts run through the translator, baseline dated 2026-10-24, in our testing. "Drawing-only" has a precise definition there, and the definition matters more than the count:
-
Drawing-only = the script compiled, ran bar-by-bar to completion, and has no
plot()at all — only drawing objects: lines, labels, boxes, tables. 366 of 1,909 scripts, 19.2% of the corpus. - Drawing-only is not silent. The 196 silent scripts from post #6 produced nothing on the test feed — no plot, no drawing, no trigger. The 366 produce drawings and nothing else. Conflating the two is the first mistake; the silent ones got their own post, these get this one.
- Drawing-only is not an error. None of the 366 threw anything. A translator that reports "success" on all of them is telling the truth — and still misleading you if you only read the CSV, because the CSV is the wrong place to look.
One scope note, stated plainly: the 366 are corpus files, and the corpus itself lives on my other machine — I can't re-open the individual drawing-only scripts from here tonight. So the five reproductions below are minimal scripts I wrote to isolate each drawing type, compiled with the local compiler and run on the series' usual feed. They are reproductions, not the corpus scripts themselves — but every number they produce was cross-checked against the raw feed, so the counts are measurements, not illustrations.
Repro 1: pivot lines — 238 drawn, 50 survive
The most common drawing-only shape in the wild is a line at every swing point: support and resistance drawn as horizontal rays. The Pine:
//@version=5
indicator("Draw repro 1: pivot lines", overlay=true)
ph = ta.pivothigh(high, 5, 5)
if not na(ph)
line.new(bar_index - 5, ph, bar_index, ph, extend=extend.right, color=color.new(color.blue, 0))
The Python is the actual output of the converter, verified tonight with the local compiler (node bin/pine2pyne.mjs, zero diagnostics). Verbatim:
from pynecore import Series
from pynecore.lib import bar_index, color, extend, high, line, na, script, ta
@script.indicator(title="Draw repro 1: pivot lines", overlay=True)
def main():
ph: Series[float] = ta.pivothigh(high, 5, 5)
if (not na(ph)):
line.new((bar_index - 5), ph, bar_index, ph, extend=extend.right, color=color.new(color.blue, 0))
Measured on 4,089 bars:
| What we counted | Result, in our testing |
|---|---|
Lines created (line.new calls that fired) |
238 |
| Lines deleted by the cap | 188 |
| Lines live at the end | 50 |
| First line ever drawn | bar 38 @ 3,345.91 — evicted |
| Oldest line still live | bar 3,228 @ 4,169.67 |
| Newest line still live | bar 4,061 @ 4,583.38 |
extend on every live line |
right — preserved |
The control column is the proof, twice over. First, the independent check: pandas finds exactly 238 pivot highs on this feed, the first at bar 38 @ 3,345.91 and the last at bar 4,061 @ 4,583.38 — the same two numbers the journal reports. Second, the arithmetic closes: 238 created − 188 deleted = 50 live, which is exactly the default max_lines_count of 50. TradingView's rule is that the 51st line deletes the oldest one, first-in-first-out; the Python port enforces the same cap, the same way. The first line this script ever drew is gone in both worlds — not because the port dropped it, but because the cap is the semantics. If your port "loses" old lines, check the cap before you blame the translator.
Repro 2: pivot labels — the text is real data
Labels are where a drawing-only script stops being decoration and starts being a data table stapled to the chart. The Pine:
//@version=5
indicator("Draw repro 2: pivot labels", overlay=true)
ph = ta.pivothigh(high, 5, 5)
pl = ta.pivotlow(low, 5, 5)
if not na(ph)
label.new(bar_index - 5, ph, "PH " + str.tostring(ph, format.mintick), style=label.style_label_down, color=color.new(color.red, 0), textcolor=color.white)
if not na(pl)
label.new(bar_index - 5, pl, "PL " + str.tostring(pl, format.mintick), style=label.style_label_up, color=color.new(color.green, 0), textcolor=color.white)
Measured: 486 labels created, 436 deleted, 50 live — and the arithmetic closes again (486 − 436 = 50, the default max_labels_count). The independent check: 238 pivot highs + 248 pivot lows = 486, exactly. And the labels carry real values, not placeholders — the first three live ones read "PH 4098.380000", "PL 3899.750000", "PH 4007.759999", and the last one reads "PL 3958.140002", which is the final pivot low on the feed (bar 4,078 @ 3,958.14). A label's text is a measurement with a bar attached to it. If you throw the labels away because "they're just drawings," you throw away 486 measurements.
Repro 3: gap boxes — 360 boxes, same cap
Fair-value-gap and range boxes are the same shape with a different object. The Pine:
//@version=5
indicator("Draw repro 3: gap boxes", overlay=true)
gapUp = low > high[1]
gapDn = high < low[1]
if gapUp
box.new(bar_index - 1, high[1], bar_index, low, bgcolor=color.new(color.green, 90))
if gapDn
box.new(bar_index - 1, low[1], bar_index, high, bgcolor=color.new(color.red, 90))
Measured: 360 boxes created (182 gap-up + 178 gap-down), 310 deleted, 50 live — 360 − 310 = 50, the default max_boxes_count, and the independent gap count on the feed is 182 + 178 = 360, exactly. Three drawing types, three caps, three times the same story: the port creates every object the script asks for and evicts exactly the ones TradingView would evict. The cap is not a port limitation. It is the chart's memory, implemented in Python.
Repro 4: the dashboard table — one object, 4,087 updates
Tables are the odd one out: a drawing-only script that behaves like a dashboard, not a chart. The Pine:
//@version=5
indicator("Draw repro 4: dashboard table", overlay=true)
var table dash = table.new(position.top_right, 2, 2)
rsi = ta.rsi(close, 14)
table.cell(dash, 0, 0, "RSI")
table.cell(dash, 1, 0, str.tostring(rsi, "#.##"))
table.cell(dash, 0, 1, "Close")
table.cell(dash, 1, 1, str.tostring(close, format.mintick))
Measured: 1 table created, 4,087 cell updates, 1 table live. The var matters — one table for the whole run, not one per bar — and the port honors it: the emitted Persistent variable is created once. The final cell values are the check: RSI reads "37.64" and Close reads "4054.280000". Both were verified independently: a pandas Wilder RSI(14) on the same feed ends at 37.64, and the last close is 4,054.28. The table is the one drawing object whose content is a single verifiable number, and it verifies.
Repro 5: the one updating ray — the idiom that works
Every serious drawing script has one version of this pattern: keep a single line, move its right end to the current bar, replace it when a new pivot arrives. If the port gets this wrong, nothing else matters. The Pine:
//@version=5
indicator("Draw repro 5: one updating ray", overlay=true)
var line ray = na
ph = ta.pivothigh(high, 5, 5)
if not na(ph)
if not na(ray)
line.delete(ray)
ray := line.new(bar_index - 5, ph, bar_index, ph, extend=extend.right, color=color.new(color.orange, 0))
if not na(ray)
line.set_x2(ray, bar_index)
Measured: 238 lines created, 237 deleted, 3,808 updates, 1 line live. The arithmetic closes a third way: the ray exists from bar 43 (the first pivot is confirmed) to bar 4,088, which is 4,046 bars; 238 of those bars create a new line, and the other 3,808 update the existing one — 238 + 3,808 = 4,046, exactly. The one surviving line ends at x1 = 4,061 @ 4,583.38 with x2 = 4,088, the last bar index: it points at the last pivot high and reaches the present. The delete–recreate–update idiom works, the var holds, and line.set_x2 tracks the current bar. This is the positive control for the whole post: the port handles the standard drawing pattern correctly.
So where is the output? The journal, not the CSV
Here is the part that would have saved me an hour if someone had told me on day one. The runner writes two things: a plot CSV and a drawing journal (NDJSON). A drawing-only script has no plots, so the CSV is 0 bytes — not corrupt, not truncated, just empty, because there is nothing to put in it. The drawings are in the journal: one create event per object, one update per set_* call, one delete per eviction, plus a final snapshot of everything still live. That journal is the deliverable. It is what a renderer would consume to repaint the chart — coordinates, colors, text, and the full lifecycle of every object.
Which means the honest answer to "what does a translator owe a drawing-only script" is this: coordinates plus lifecycle, not pixels. The port owes you every object the script created, with its real coordinates and its real text, and an exact record of which ones the cap evicted and when. It does not owe you a picture — there is no canvas in a Python backtest, and any tool that shows you one is rendering the journal for you, not recovering something the translator hid. If your workflow reads only the CSV, a drawing-only port will always look empty. Read the journal.
Both things are true at once: the port is faithful — 238 lines created, 50 live, every count cross-checked — and the default output file is empty. The contradiction dissolves once you know there are two output channels and drawings live in the second one.
Rules I now follow
- Count the drawings before reading the code. A run with 0 bytes of CSV and 238 journal events is a different problem from a run with 0 bytes and 0 events. Diagnose the channel first, correctness second.
-
Check the cap before blaming the translator.
max_lines_count,max_labels_count,max_boxes_countall default to 50, in Pine and in the port. Old objects being gone is the semantics, not data loss. -
Treat label text as data. A label that says
"PH 4098.380000"is a measurement with a bar attached. Verify it against the feed the same way you would verify a plot value. - Keep drawing-only and silent apart. 366 scripts draw and never plot; 196 run and produce nothing. Different categories, different fixes — don't let one number stand for both.
- A reproduction beats an explanation. Five small scripts, five runs, one table. Every claim in this post can be re-run from the code printed above — and the journal is the receipt.
Next in the series: the translator got better — one fix family, one script that used to fail, before and after.
What's the drawing your port drops first — the line, the label, or the table? And did you find it in the CSV, or somewhere else? I read every comment — the lost-drawing stories are what the next posts are built from.
This conversion work was done by Pine2Py, the tool I build for exactly this job: paste a Pine script, get PyneCore-flavored Python back, diagnostics included when something can't be translated. The runtime is the open-source PyneCore project, with a patched build we ship for the two constructs stock PyneCore doesn't handle — details are on the site. It's free to try — every account gets 3 conversions, no card — and Pro is $12/month if you end up converting a whole library. No return promises, ever: a translator moves your logic, it doesn't make it profitable.
Top comments (0)