Introduction
OpenPine is an open source implementation of TradingView Pine Script v6, written in Rust. It provides a complete pipeline to parse, type-check, compile, and execute Pine scripts outside of TradingView.
What is Pine Script?
Pine Script is the programming language created by TradingView for writing custom technical analysis indicators and trading strategies. It is designed to be simple yet powerful, operating on a bar-by-bar execution model where scripts process one candlestick at a time.
What is OpenPine?
OpenPine takes the Pine Script language and makes it available as an independent, embeddable engine. You can:
- Run Pine scripts on your own candlestick data and collect outputs (plots, alerts, strategy orders)
- Embed the engine in Rust, C, or C++ applications
- Use the LSP for editor support with diagnostics, completions, hover, go-to-definition, and more
- Extend with custom native functions and library loaders
Architecture
The processing pipeline is:
Each stage is a separate crate:
| Crate | Role |
|---|---|
openpine-parser | nom-based parser producing span-annotated ASTs |
openpine-visitor | Semantic analysis, type checking, name resolution |
openpine-compiler | AST to VM instructions with 3 optimization passes |
openpine-vm | Bar-by-bar runtime engine |
openpine-loader | Module resolution (imports, prelude, stdlib) |
openpine-builtins | Embedded prelude and stdlib Pine sources |
openpine-lsp | Language Server Protocol implementation |
openpine-capi | C/C++ FFI bindings |
Current Status
- Language version: Pine Script v6 only
- Goal: Run Pine scripts, produce plots/alerts/strategy events, support common standard library functions
- Status: Under active development; some features are incomplete or may behave differently from TradingView
Next Steps
- Quick Start — build and run your first script
- Language Basics — learn Pine Script syntax in OpenPine
- Integration — embed the engine in your Rust application