{"id":26079,"library":"pinets","title":"PineTS","description":"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.","status":"active","version":"0.9.13","language":"javascript","source_language":"en","source_url":"https://github.com/QuantForgeOrg/PineTS","tags":["javascript","Pine Script","Pine","PineScript transpiler","PineScript runtime","PineScript to JavaScript","PineScript to TypeScript","TradingView","Quant","typescript"],"install":[{"cmd":"npm install pinets","lang":"bash","label":"npm"},{"cmd":"yarn add pinets","lang":"bash","label":"yarn"},{"cmd":"pnpm add pinets","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for fetching market data from providers like Binance","package":"node-fetch","optional":false},{"reason":"Required for TypeScript runtime helpers","package":"tslib","optional":true}],"imports":[{"note":"ESM-only. CommonJS require will not work.","wrong":"const PineTS = require('pinets')","symbol":"PineTS","correct":"import { PineTS } from 'pinets'"},{"note":"Provider is an enum; access via Provider.Binance.","wrong":"import { Binance } from 'pinets'","symbol":"Provider","correct":"import { Provider } from 'pinets'"},{"note":"Default export is the same as named. Both work.","wrong":"import { default as PineTS } from 'pinets'","symbol":"PineTS (default)","correct":"import PineTS from 'pinets'"},{"note":"For custom data sources; not needed with built-in providers.","wrong":null,"symbol":"DataProvider","correct":"import { DataProvider } from 'pinets'"},{"note":"Type for errors thrown by Pine Script execution.","wrong":null,"symbol":"PineScriptError","correct":"import { PineScriptError } from 'pinets'"}],"quickstart":{"code":"import { PineTS, Provider } from 'pinets';\n\nconst pineTS = new PineTS(Provider.Binance, 'BTCUSDT', '1h', 100);\n\nasync function main() {\n  const { plots } = await pineTS.run(`\n    //@version=5\n    indicator(\"EMA Cross\")\n    plot(ta.ema(close, 9), \"Fast\", color.blue)\n    plot(ta.ema(close, 21), \"Slow\", color.red)\n  `);\n\n  console.log('Fast EMA:', plots['Fast'].data.slice(0, 5));\n  console.log('Slow EMA:', plots['Slow'].data.slice(0, 5));\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Initializes PineTS with Binance BTCUSDT 1h data and runs a simple EMA cross Pine Script, logging the first 5 values of each plot."},"warnings":[{"fix":"Replace provider strings with enum values: Provider.Binance, Provider.BinanceFutures, etc.","message":"Provider enum changed in v0.8.0: old string-based provider names (e.g., 'binance') no longer accepted. Use Provider.Binance.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Access plots via plots['name'] instead of destructuring from array.","message":"run() method returns object with `plots` key instead of array since v0.9.0.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Switch to ES module imports: import { PineTS } from 'pinets'.","message":"Using require('pinets') is deprecated as of v0.9.0. Package is ESM-only moving forward.","severity":"deprecated","affected_versions":">=0.9.0"},{"fix":"Use backticks for multi-line Pine code to avoid escaping issues.","message":"Pine Script strings must use backticks or escaped quotes inside JavaScript strings. Template literals work best.","severity":"gotcha","affected_versions":"all"},{"fix":"Request extra bars (e.g., 200) to account for missing data or warmup.","message":"Data fetched from Binance may have gaps; ensure at least 100 bars for reliable indicator calculations.","severity":"gotcha","affected_versions":"all"},{"fix":"Filter out NaN values or slice after warmup period (e.g., plots['SMA 20'].data.slice(20)).","message":"Plot data is returned as arrays with the same length as the requested bar count; first elements may be NaN due to indicator warmup.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install pinets' and ensure you're using ESM imports.","cause":"Package not installed or wrong import path.","error":"Error: Cannot find module 'pinets'"},{"fix":"Use 'import { Provider } from 'pinets'' and access Provider.Binance.","cause":"Provider enum not imported correctly.","error":"TypeError: Provider.Binance is undefined"},{"fix":"Switch to ES module syntax or add 'type': 'module' in package.json.","cause":"Using CommonJS require on an ESM-only package.","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Check Pine Script code for errors and ensure version pragma is included.","cause":"Pine Script syntax error (e.g., missing //@version=5).","error":"PineScriptError: line X: ... (Pine script compilation error)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}