Skip to content

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:

OpenPine processing pipelineOpenPine processing pipeline

Each stage is a separate crate:

CrateRole
openpine-parsernom-based parser producing span-annotated ASTs
openpine-visitorSemantic analysis, type checking, name resolution
openpine-compilerAST to VM instructions with 3 optimization passes
openpine-vmBar-by-bar runtime engine
openpine-loaderModule resolution (imports, prelude, stdlib)
openpine-builtinsEmbedded prelude and stdlib Pine sources
openpine-lspLanguage Server Protocol implementation
openpine-capiC/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

Released under the MIT License.