Pine Script® → Python Converter

in Seconds

Your Pine Script code, running in Python

This is not another AI / LLM based Pine Script converter.
Instead, it's a deterministic, reliable compiler!

1,000/1,000 real TradingView scripts compile & run. See the proof

//@version=6
strategy("BarUpDn Strategy", overlay=true,
         default_qty_type = strategy.percent_of_equity,
         default_qty_value = 10)

maxIdLossPcnt = input.float(1, "Max Intraday Loss(%)")

strategy.risk.max_intraday_loss(maxIdLossPcnt,
     strategy.percent_of_equity)

if (close > open and open > close[1])
    strategy.entry("BarUp", strategy.long)

if (close < open and open < close[1])
    strategy.entry("BarDn", strategy.short)
"""
@pyne edge
"""
from pynecore.lib import close, input, open, script, strategy

@script.strategy('BarUpDn Strategy', overlay=True, default_qty_value=10,
                 default_qty_type=strategy.percent_of_equity)
def main(
    maxIdLossPcnt=input.float(1, 'Max Intraday Loss(%)')
):
    strategy.risk.max_intraday_loss(maxIdLossPcnt, strategy.percent_of_equity)
    if close > open and open > close[1]:
        strategy.entry('BarUp', strategy.long)
    if close < open and open < close[1]:
        strategy.entry('BarDn', strategy.short)

The Python You Get Back

This is what PyneComp writes for a small Pine indicator. The notes show where each part of your script ends up.

"""
@pyne edge

This code was compiled by PyneComp v6.1.3 — the Pine Script to Python compiler.
Run with open-source PyneCore: https://pynecore.org
Compile Pine Scripts online at PyneSys: https://pynesys.io
"""
# Trend band: an EMA with an ATR envelope around it.

from pynecore.lib import bgcolor, close, color, input, na, plot, script, ta
from pynecore.types import PersistentSeries


@script.indicator("Trend band", overlay=True)
def main(
    # Inputs
    len=input.int(20, "Length"),  # EMA and ATR length
    mult=input.float(2.0, "Multiplier")  # band width in ATRs
):
    def band(center: float, width: float):
        """
        The band around a center line.

        :param center: The center line
        :param width: The distance of each edge from the center
        :return: The upper and the lower edge
        """
        return (center + width, center - width)

    basis = ta.ema(close, len)
    upper, lower = band(basis, ta.atr(len) * mult)

    # A close above the upper edge starts an uptrend,
    # a close below the lower edge ends it.
    up: PersistentSeries[bool] = False
    if close > upper:
        up = True
    elif close < lower:
        up = False

    # The trend turns on the bar where up differs from the bar before.
    turn = up != up[1]

    plot(basis, 'Basis', color.green if up else color.red)
    plot(upper, 'Upper', color.gray)
    plot(lower, 'Lower', color.gray)
    bgcolor(color.new(color.yellow, 80) if turn else na)


if __name__ == "__main__":
    from pynecore.standalone import run
    run(__file__)
  • Lines 1–7 Every file starts with a @pyne docstring. It marks the file as Pyne code, so PyneCore runs it the way TradingView runs your script, bar by bar.
  • Line 8 // Trend band: an EMA with an ATR… The comments at the top of your script come right after it.
  • Lines 15–19 len = input.int(20, "Length") // EMA and ATR length Inputs become the parameters of main. A comment at the end of a line stays at the end of that line.
  • Lines 20–28 //@function The band around a center line. //@function, //@param and //@returns become a docstring, which your editor shows when you hover over a call.
  • Lines 30–31 [upper, lower] = band(basis, …) Your names stay as you wrote them.
  • Lines 35 and 42 var bool up = false … up[1] var keeps up from bar to bar, and up[1] reads it one bar back. The compiler sees both and makes up a PersistentSeries. Variables you never look back on, like basis, stay plain Python values.
  • Lines 48–49 Two blank lines around a top-level function, at most one inside it: the spacing follows PEP 8, the Python style guide.

Tested on 44,000+ Real Scripts

Scripts of every Pine version, nearly 3,000 of them broken. A script TradingView accepts must never be refused.

Pine v1 to v6

Old scripts compile directly and convert to v6. The lines that need no change come back exactly as you wrote them.

Errors Where You Made Them

It rejects what TradingView rejects, and the error points at the line in your Pine script.

Same Script, Same Code

No LLM guessing. The compiler needs less than a millisecond for a typical v6 script.

How It Works

Upload Your Pine Script

Paste or upload your Pine Script in the web app to convert it online, or send it from the PyneCore CLI or the API.

Upload Pine Script

We Convert to Python (PyneCore)

Our system translates your Pine Script to Python code that uses our PyneCore library. Generated code is human-readable. You can use and develop it easily.

Convert to Python

Run on Your Machine

Execute the generated Python code locally or on your own server. PyneCore allows you to run your compiled scripts easily with its friendly CLI.

Run on Your Machine

Keep Working on It in PyneIDE

Open the .pine file or the generated Pyne code in PyneIDE, run it on a chart and step through it bar by bar. Pine files recompile when they change, and the Pyne code runs without an account.

Install PyneIDE for free

Proof, Not Promises

Don't take our word for it. Pyne in the Wild takes the most popular open-source Pine Script indicators and strategies published on TradingView, compiles each one to Python, and runs it with PyneCore. Wherever TradingView's output can be exported, every plotted value and every trade is compared against it — bar by bar, bit by bit.

The remaining 0.229% of bars? Within 1e-9 relative tolerance — last-digit floating-point rounding, documented per script, because “close enough” deserves a number too. Every result is reproducible: the corpus pins the exact source of each script with a SHA-256 hash.

Browse the Full Report

Script-by-script results at wild.pynesys.io · snapshot 2026-10-24 · the corpus keeps growing

1,000
real TradingView scripts
502 indicators, 498 strategies
100%
compile and run
1,000/1,000, zero failures
99.771%
of 132 million compared bars
bit-exact vs TradingView
0
scripts diverge from TradingView
across 353,577 compared trades

Try It For Free

Not ready to subscribe yet?
Convert up to 3 scripts for free with our Discord bot.

Go to #pine-compiler-bot channel in PyneSys Discord Server and use the /pyne-help command.

Discord bot conversions support Pine Script v4, v5, and v6 files up to 25KB.

Join Our Discord
3 free conversions
Discord Bot Preview

CLI & API Integration

The PyneCore CLI is the primary interface today — run your Pine Scripts locally with a single command. For backend automation, the same compiler is exposed as an HTTP API. Pick whichever fits your workflow; both call the same deterministic compiler.

PyneCore CLI

# One-shot: compile via the API, then run locally on your OHLCV data
pyne run my_strategy.pine BTCUSDT_1D.ohlcv

# Or compile only — produces a .py file you can edit and commit
pyne compile my_strategy.pine

The CLI re-compiles only when the .pine file is newer than its generated .py, so unchanged scripts never hit the API. Set your key once via PYNESYS_API_KEY, the --api-key flag, or workdir/config/api.toml.

HTTP API

# POST a Pine Script — get readable PyneCore Python back as plain text
curl -X POST https://api.pynesys.io/compiler/compile \
  -H "Authorization: Bearer $PYNESYS_API_KEY" \
  -F "script=@my_strategy.pine"

POST /compiler/compile returns the compiled Python directly. Identical scripts are served from the server-side cache instantly and do not consume your compile quota. Full interactive reference at api.pynesys.io/docs.

Key Features

  • Personal Bearer API keys — create, rotate, or revoke any time from your dashboard
  • Smart server-side cache — re-compiling the same Pine Script returns instantly and does not bill your quota
  • Mtime-aware CLI — skips the API entirely when your .pine source hasn't changed
  • Output is human-readable PyneCore Python — read it, edit it, version-control it
  • Interactive OpenAPI reference at api.pynesys.io/docs

Compiler Pricing

The same subscription covers Pine Script compilation in PyneIDE, from the CLI and through the API.

Free Discord trial

Try the compiler with 3 free script conversions through our Discord bot. Join the server and open the #pine-compiler-bot channel to get started.

Try on Discord

🌱 Seed

$8 / month

For bringing one or two Pine indicators over to Pyne. Convert them here and keep working on the Pyne code in PyneIDE, where running and debugging it is free.

  • 5 script conversions per day
  • 1 script conversion per hour
  • Every 3 failed conversions count as 1 toward your limits
  • 1 API key

🌿 Sprout

$18 / month

For converting Pine scripts regularly. Each conversion gives you Pyne code that you can edit, run and debug in PyneIDE for free.

  • 30 script conversions per day
  • 5 script conversions per hour
  • Every 3 failed conversions count as 1 toward your limits
  • 2 API keys

🌲 Grower

$28 / month

For writing Pine Script every day in PyneIDE. The IDE recompiles your script each time you run it after an edit, so this plan allows 60 compiles an hour.

  • 700 script conversions per week
  • 60 script conversions per hour
  • Every 3 failed conversions count as 1 toward your limits
  • 5 API keys

🌳 Forest

$48 / month

For staying with Pine Script and using PyneIDE all day. Your scripts stay in Pine, so you get the IDE's debugger and live chart and can keep working on TradingView too.

  • 2,100 script conversions per week
  • 120 script conversions per hour
  • Every 3 failed conversions count as 1 toward your limits
  • 10 API keys

Plan Comparison

SeedSproutGrowerForest
Price$8$18$28$48
Pine compiles5 per day30 per day700 per week2100 per week
Pine compiles per hour1560120
API Keys12510
Max Script Size25 KB50 KB150 KB300 KB
  • Each run of a changed .pine file is one compile. Unchanged scripts come from the cache and don't count.
  • Converting a Pine v4 or v5 script to v6 doesn't use your quota.
  • The generated Pyne code is yours to read, edit and keep.

Most scripts convert 1:1 and run as-is. When one doesn't, the generated Python is readable, so a small manual edit usually gets it working. See the FAQ and the PyneCore Compatibility page for details.

Join Our Community

Connect with other traders, developers, and the PyneSys team.

Frequently Asked Questions

No. Keep charting and publishing on TradingView, and develop your scripts in PyneIDE. There they are files in your own git repository, and you can step through them bar by bar in a debugger, which TradingView doesn't have.

It automatically transforms your Pine Script code into Python-compatible "Pyne" code. This Pyne code can be run in an open-source system called PyneCore, which preserves Pine semantics but in Python form.

Classic compiler! We don't use any LLM/GPT-based generation, only deterministic transformation rules (full lexical parser → AST → transform → codegen pipeline). This ensures reliable, predictable conversion results every time.

For PyneIDE, only VS Code and the extension. PyneIDE downloads its own Python and the PyneCore runtime the first time you need them, so you don't need a system Python.

Without the IDE, you can use the compiler through the web app, the PyneCore CLI or the HTTP API. The CLI calls the API and only converts a script that isn't in the cache yet.

With the PyneCore system, it can run on any platform: Linux, macOS, Windows. The system requires Python 3.11+ and doesn't use cumbersome external dependencies.

Pine Script is TradingView's programming language. We're not copying or reverse-engineering it, but building an independent system that is functionally compatible with it. This means the same logic and behavior applies, but in Python language, with full control and customizability.

No. The compiler only converts Pine Script to Pyne code, and conversion in the other direction isn't planned for the near future.

You don't need it to backtest locally and keep the script running on TradingView. Keep the Pine Script file as your source and run it with PyneCore or PyneIDE, which compile it through the PyneSys compiler API in the background (this needs an API key from one of the plans). When you're happy with the results, publish the same file on TradingView. You only work with the Python side if you want to.

Almost always. Of the 1,000 published TradingView scripts in Pyne in the Wild, 1,000 convert as they are, and 1,353 of the 1,353 outputs that can be compared with TradingView match it: plots bar by bar, strategies trade by trade.

If a script still misbehaves, the generated Python is human-readable, and the Compatibility page shows the status of every Pine Script feature in PyneCore.

Found a bug or a missing feature? Please flag it on Discord or GitHub — that's the fastest way to get it fixed.

PyneComp compiles scripts written in Pine Script v1 through v6 to Pyne code. It can also upgrade older scripts to Pine Script v6.

This website uses cookies and similar technologies. By continuing to use the site, you accept this. Details in our Privacy Policy.