PYNESCRIPT: ONLINE/ANTLR4 V5+V6
P
Y
N
E
ULL22ms

Deterministic Pine Script™ Evaluation.
At the Edge.

A deterministic Pine Script\u2122 v5 and v6 runtime built on ANTLR4 and an ASDL AST. pynescript runs on Cloudflare\u00AE Workers via pyne-worker and pine-worker — no bar limits, no infrastructure overhead, no vendor lock-in.

[500+]

Pine v5 & v6 Builtins

[Uncapped]

Max Backtest Bars

[<15ms]

Edge Signal Latency

[$0]

Infra Monthly Cost

ANTLR4 Pine v5/v6
Cloudflare® Edge Python & TS
[ EXPLORE PYNESCRIPT ▼ ]
FREEDOM
01 // THE MONOPOLY BROKEN

[LEAVING THE BARBED WIRE BEHIND]

TradingView\u00AE has controlled the Pine Script\u2122 ecosystem for over a decade. Zero open-source runtimes. No way to self-host. Strict bar limits and mandatory subscriptions. pynescript dissolves these constraints.

CapabilityTradingView®Freqtrade3commaspyne-worker / pynescript
100% Pine Script&trade; Syntax Yes No (Python rewrite) No Yes (100% v5/v6 AST)
Open Source Runtime No (Proprietary) Yes (Python) No Yes (AGPL v3)
Free / Self-Hostable No ($50&ndash;$200/mo) Yes (VPS required) No ($30&ndash;$150/mo) Yes (Cloudflare&reg; Free Tier)
Cloudflare&reg; Edge Infrastructure No No No Yes (<15ms Global Edge)
Backtest > 20k Bars No (20k limit) Yes No Yes (Uncapped R2 Storage)
Programmatic REST/RPC API No (Limited webhooks) Yes Yes Yes (Open REST & TS API)
Direct Strategy Events &rarr; Execution No (Manual alert setup) Yes (Custom code) Yes Yes (Built-in trade-worker)
Multi-Strategy Batch Execution No (1 chart per tab) Yes Yes Yes (Parallel edge isolates)
02 // DUAL RUNTIME ARCHITECTURE

[DUAL RUNTIME PARADIGM]

Two runtimes, one grammar. The Python reference engine guarantees AST parsing fidelity through ANTLR4. Cloudflare\u00AE Workers deliver deterministic, sub-15ms execution at the global edge. pynescript is the bifurcated execution model that makes this possible.

Reference Engine

pynescript (Python Core)

~8,000 LOC Python

  • Full ANTLR4 Grammar for Pine v5 & v6
  • ASDL-generated AST (25+ node types)
  • 500+ builtins across 25+ namespaces
  • Strategy event state machine (entry/exit/close)
  • Language Server Protocol (pygls) & VS Code extension
  • Flask Pro REST API & CLI suite
ANTLR4 PARSER100% PARITY
Edge Production

pyne-worker (Python CF Worker)

~1,100 LOC Python

  • Cloudflare&reg; Workers Python Runtime
  • Constant-time HMAC API authentication
  • Sliding window rate limiting (100 req/60s)
  • Cloudflare&reg; R2 gzipped JSONL bar fetcher
  • StrategyEvent &rarr; trade-worker Webhook forwarding
  • 25/25 production parity test harness passing
ANTLR4 PARSER100% PARITY
V8 High-Speed

pine-worker (TypeScript Edge)

~8,000 LOC TypeScript

  • ANTLR4 TypeScript Parser from same grammar
  • Zod AST schemas + visitor evaluator
  • 10 core ported builtin modules (ta, math, strategy, arrays, strings, drawing, plotting, input, alerts, utility)
  • Zero-dependency edge V8 isolate execution
  • Service binding integration with hoox trade-worker
  • Chart CSV exporter for TradingView&reg; compatibility
ANTLR4 PARSER100% PARITY

Pine Script™ Strategy Lifecycle Topology

INPUTPine Script&trade; Sourcev5 / v6 Code
PARSERANTLR4 Lexer/ParserASDL AST Nodes
EVALUATOR500+ Builtinsta.* / math.* / strategy.*
EMITTERStrategyEventEntry / Exit / Close
EXECUTIONtrade-worker<15ms Exchange Ack
[BENCHMARK]3x 1500-line strategies on pyne-worker: ~200–1000ms warm / ~1200–4000ms cold. Workers stays warm ~5-10min.
View pyne-worker Benchmarks
03 // INTERACTIVE AST & EVALUATOR SANDBOX

Inspect the Engine in Action

Trace a Pine Script\u2122 strategy from source through the ASDL AST, into strategy state machine evaluation, and out as structured trade events for Cloudflare\u00AE Workers execution.

//@version=6
strategy("HOOX Edge Grid Master", overlay=true, initial_capital=10000)

// Strategy Inputs
fastLength = input.int(12, "Fast EMA")
slowLength = input.int(26, "Slow EMA")
gridLevels = input.int(5, "Grid Levels")

// Builtin Indicators (ta.* namespace)
fastEma = ta.ema(close, fastLength)
slowEma = ta.ema(close, slowLength)

// Entry Signal Logic
longCondition = ta.crossover(fastEma, slowEma)
if (longCondition)
    strategy.entry("Grid_Long_1", strategy.long, qty=0.25)
    strategy.exit("TP_Exit_1", "Grid_Long_1", profit=150, loss=50)

// Visual Plotting
plot(fastEma, color=color.cyan, title="Fast EMA")
plot(slowEma, color=color.purple, title="Slow EMA")
STATUS: PARSED & EVALUATED (100% PARITY)
04 // OPEN SOURCE TOOLCHAIN & ECOSYSTEM

Modular Pine Script™ Stack

Use the Python package locally, deploy to Cloudflare\u00AE Workers in Python or TypeScript, or integrate via VS Code. Every component is AGPL v3 open source.

CORE ENGINE

pynescript

Python reference engine with ANTLR4 parser, ASDL AST, 500+ builtins, REPL, and linter.

pip install pynescript
PYTHON EDGE WORKER

pyne-worker

Production Python Cloudflare&reg; Worker with R2 data ingestion and trade-worker event forwarding.

hoox workers deploy pyne-worker
TS EDGE WORKER

pine-worker

High-performance TypeScript Cloudflare&reg; Worker port for pure V8 isolate execution.

bun run dev --filter pine-worker
CHARTING PWA

superchart

Open-source PWA charting client with native pynescript Pine Script&trade; integration.

bun create superchart@latest
VS CODE EXTENSION

pynescript-lsp

VS Code extension providing auto-complete, hover docs, and inlay hints for Pine Script&trade;.

code --install-extension pynescript-lsp
FLASK REST API

Flask Pro API

High-throughput REST API server for batch backtesting and strategy event emission.

python -m backend.app
[ECOSYSTEM]Every component open-source under AGPL v3. Deploy free on Cloudflare® Workers. No vendor lock-in. Ever.
05 / Open Source Philosophy

[OPEN SOURCE BY DESIGN]

Pine Script\u2122 evaluation has been a closed ecosystem since TradingView\u00AE launched. The grammar was proprietary. The runtime was proprietary. If you wanted to run Pine outside their browser, you couldn\u2019t. pynescript changes that. The code is AGPL v3 open source. Revenue comes from managed hosting, never from software freedom.

The Value-Add Model

Walled Garden
  • Closed-source evaluator runtime
  • Paywall the core runtime
  • API keys that expire monthly
  • Obscure the grammar and parser
pynescript Model
  • Open-source evaluator (AGPL v3)
  • Free self-host + free basic SaaS
  • Charge for managed hosting, not code
  • Publish everything, let anyone fork

Open Source

$0 / mo

AGPL v3 Copyleft

  • &check;Full Python evaluator & all 500+ builtins
  • &check;pyne-worker & pine-worker source access
  • &check;ANTLR4 grammar & ASDL definitions
  • &check;All tests & parity test harness
  • &check;Unlimited self-hosting on Cloudflare®
RECOMMENDED

Pro SaaS

$29 / mo

Managed Edge Cloud

  • &check;5 active Pine Script™ strategies
  • &check;10 symbol streams (real-time)
  • &check;Zero-config managed Cloudflare® R2 data
  • &check;Automatic trade-worker event dispatch
  • &check;Priority support & backtest engine

Commercial / Enterprise

Custom

Proprietary License

  • &check;Non-AGPL commercial license rights
  • &check;SLA & dedicated infrastructure
  • &check;Custom builtin integration support
  • &check;On-premise deployment package
  • &check;Direct engineering access

[THE PHILOSOPHY] Software freedom means the code survives any single company. If someone builds a better service on top of this codebase, that\u2019s a win. The code is open. People choose the best service.

06 // ZERO INFRASTRUCTURE COST PIPELINE

The $0/Month Self-Hosted Quant Stack

Every component runs inside Cloudflare\u00AE free tier limits. Zero monthly costs. Zero maintenance. Zero lock-in.

STEP 01

TradingView&reg; Alert or Custom Webhook

Fire your signal directly to the edge gateway. No browser dependency. No tab crashes.

INFRA COST: $0/MOFREE TIER
STEP 02

pyne-worker / pine-worker Evaluation

Evaluates Pine Script&trade; strategy on Cloudflare&reg; Workers in <15ms. Emits typed StrategyEvent.

INFRA COST: $0/MOFREE TIER
STEP 03

trade-worker Execution

Validates HMAC risk limits and dispatches execution orders to Binance/Coinbase APIs.

INFRA COST: $0/MOFREE TIER
STEP 04

Cloudflare&reg; Pages Dashboard

Real-time P&L visualization and trade reporting stored in Cloudflare&reg; D1.

INFRA COST: $0/MOFREE TIER

Infrastructure Cost Comparison

TradingView® + 3commas$230/mo
  • TradingView Premium: $200/mo
  • 3commas Pro: $30/mo
  • 20k bar backtest limit
  • Webhook latency: 200-500ms
  • Vendor lock-in
pynescript Stack$0/mo
  • Cloudflare® Workers: Free (100k req/day)
  • Cloudflare® R2: Free (10GB)
  • Cloudflare® D1: Free (5M rows)
  • Uncapped backtesting bars
  • Sub-15ms edge latency
  • Full AGPL v3 source access
[TOTAL INFRASTRUCTURE COST]$0.00 / month on Cloudflare® Free Tier vs $230.00 / month for TradingView® Premium + 3commas.