PineTS
raw JSON → 0.9.13 verified Fri May 01 auth: no javascript
PineTS is an open-source transpiler and runtime that executes Pine Script (TradingView's indicator language) in Node.js, browsers, and other JavaScript runtimes. Version 0.9.13 is the latest stable release, with active development and biweekly releases. Key differentiators include 1:1 syntax compatibility with Pine Script v5, support for multiple data providers (Binance, CSV, custom), and full TypeScript types. Unlike alternatives (e.g., pine-js), PineTS is a full runtime with a built-in transpiler and provider abstraction, enabling off-platform execution of indicators and strategies for backtesting, alerts, and ML pipelines.
Common errors
error Error: Cannot find module 'pinets' ↓
cause Package not installed or wrong import path.
fix
Run 'npm install pinets' and ensure you're using ESM imports.
error TypeError: Provider.Binance is undefined ↓
cause Provider enum not imported correctly.
fix
Use 'import { Provider } from 'pinets'' and access Provider.Binance.
error SyntaxError: Unexpected token 'export' ↓
cause Using CommonJS require on an ESM-only package.
fix
Switch to ES module syntax or add 'type': 'module' in package.json.
error PineScriptError: line X: ... (Pine script compilation error) ↓
cause Pine Script syntax error (e.g., missing //@version=5).
fix
Check Pine Script code for errors and ensure version pragma is included.
Warnings
breaking Provider enum changed in v0.8.0: old string-based provider names (e.g., 'binance') no longer accepted. Use Provider.Binance. ↓
fix Replace provider strings with enum values: Provider.Binance, Provider.BinanceFutures, etc.
breaking run() method returns object with `plots` key instead of array since v0.9.0. ↓
fix Access plots via plots['name'] instead of destructuring from array.
deprecated Using require('pinets') is deprecated as of v0.9.0. Package is ESM-only moving forward. ↓
fix Switch to ES module imports: import { PineTS } from 'pinets'.
gotcha Pine Script strings must use backticks or escaped quotes inside JavaScript strings. Template literals work best. ↓
fix Use backticks for multi-line Pine code to avoid escaping issues.
gotcha Data fetched from Binance may have gaps; ensure at least 100 bars for reliable indicator calculations. ↓
fix Request extra bars (e.g., 200) to account for missing data or warmup.
gotcha Plot data is returned as arrays with the same length as the requested bar count; first elements may be NaN due to indicator warmup. ↓
fix Filter out NaN values or slice after warmup period (e.g., plots['SMA 20'].data.slice(20)).
Install
npm install pinets yarn add pinets pnpm add pinets Imports
- PineTS wrong
const PineTS = require('pinets')correctimport { PineTS } from 'pinets' - Provider wrong
import { Binance } from 'pinets'correctimport { Provider } from 'pinets' - PineTS (default) wrong
import { default as PineTS } from 'pinets'correctimport PineTS from 'pinets' - DataProvider
import { DataProvider } from 'pinets' - PineScriptError
import { PineScriptError } from 'pinets'
Quickstart
import { PineTS, Provider } from 'pinets';
const pineTS = new PineTS(Provider.Binance, 'BTCUSDT', '1h', 100);
async function main() {
const { plots } = await pineTS.run(`
//@version=5
indicator("EMA Cross")
plot(ta.ema(close, 9), "Fast", color.blue)
plot(ta.ema(close, 21), "Slow", color.red)
`);
console.log('Fast EMA:', plots['Fast'].data.slice(0, 5));
console.log('Slow EMA:', plots['Slow'].data.slice(0, 5));
}
main().catch(console.error);