Conversion example · Drawing-only

Pivot lines: Pine Script drawing objects to Python

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

draw_lines.pinePine Script v5
//@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

draw_lines.pyPython · PyneCore
"""
@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:

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.