Conversion example · Drawing-only
Pivot lines: Pine Script drawing objects to Python
Example conversion · Published November 13, 2026
Not every Pine script plots something. In our testing of 1,909 real scripts, 366 of them — 19.2% — never call plot() at all: they only draw. Lines at swing points, labels with prices, boxes around gaps, a dashboard table. This page converts one of those scripts — a horizontal line at every pivot high — and shows what the Python port actually gives you, because it is not what you expect: the run's output file is empty, and the drawings live somewhere else.
The Python below is not hand-written. It is the actual output of the Pine2Py converter, run on this exact Pine source with the local compiler (node bin/pine2pyne.mjs), with zero diagnostics — nothing unsupported, nothing dropped.
The Pine original
//@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 output
"""
@pyne
"""
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))What the run produced
We ran the Python on 4,089 bars of CSI 300 daily data (2010-01-04 to 2026-11-06) with the runtime's drawing journal switched on, so every line creation and deletion is recorded. The numbers:
- 238 lines created — one per pivot high. An independent pandas count of pivot highs on the same feed finds exactly 238, the first at bar 38 @ 3,345.91 and the last at bar 4,061 @ 4,583.38.
- 188 lines deleted, 50 live at the end — 238 − 188 = 50, exactly the default
max_lines_countof 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 oldest line still live starts at bar 3,228 @ 4,169.67; the first line ever drawn (bar 38) is gone in both worlds — not dropped by the port, but evicted by the cap, which is the semantics. - Every live line keeps
extend=extend.right— the ray direction survives the conversion. - The run CSV is 0 bytes. A drawing-only script has no plots, so the standard plot output file is empty — not corrupt, just empty. The drawings are in the journal: one
createevent per line, onedeleteper eviction, plus a final snapshot of the 50 lines still live. That journal is the deliverable — it is what a renderer would consume to repaint the chart.
The same pattern holds for the other drawing types, measured the same way on the same feed: 486 pivot labels created (238 highs + 248 lows) with 50 live, 360 gap boxes with 50 live, one dashboard table with 4,087 cell updates whose final cells read RSI 37.64 and Close 4,054.28 — both verified against the feed. The full teardown, with all five scripts, is in our tutorial series: the 196 silent scripts and the drawing-only follow-up.
What a translator owes a drawing-only script
Coordinates plus lifecycle, not pixels. The port owes you every object the script created, with its real coordinates and 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. If your workflow reads only the CSV, a drawing-only port will always look empty. Read the journal.
Check the cap before blaming the translator. max_lines_count, max_labels_count and max_boxes_count all default to 50, in Pine and in the port. Old objects being gone is the semantics, not data loss.
Try it on your own script
Paste this Pine script — or your own — into the converter on the home page and compare the output. Every account gets 3 free conversions, no card required; Pro is $12/month via Paddle for unlimited conversions.
The output runs on the open-source PyneCore runtime. We ship a patched runtime build for the two constructs stock PyneCore doesn't handle yet — details are on the home page. Pine2Py translates code; it does not provide investment advice, and no backtest result on this page is a promise about any strategy's future performance.