npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pinets

v0.5.0

Published

[![npm version](https://img.shields.io/npm/v/pinets.svg?style=flat-square)](https://www.npmjs.com/package/pinets) [![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg?style=flat-square)](https://opensource.org/licenses/AGPL-3.0)

Downloads

663

Readme

npm version License: AGPL-3.0 Coverage Documentation Reddit

This project aims to provide a Javascript/Typescript port for Tradingview's Pine Script. The current version does not run Pine Script directly, instead it runs a close Javascript equivalent called PineTS.

PineTS makes it possible to migrate Pine Script v5+ indicators to Javascript/Typescript, in order to run them in a Javascript environment.

Disclaimer

PineTS is an independent project and is not affiliated with, endorsed by, or associated with TradingView or Pine Script™. All trademarks and registered trademarks mentioned belong to their respective owners.

Overview

PineTS enables seamless conversion of Pine Script indicators to JavaScript/TypeScript code. It preserves the original functionality and behavior while providing robust handling of time-series data processing, technical analysis calculations, and Pine Script's distinctive scoping mechanisms.

See it in action

Bellow are two ports of Pine Script indicators running in the browser. PineTS is used to generate plot data, and tradingview light weight chart is used to display the plot.

Key Features

  • Pine Script Compatibility: Supports Pine Script v5+ syntax and functionality
  • High Precision: Aims for the same precision as Pine Script (up to the 8th digit)
  • Time-Series Processing: Handles historical data and series operations
  • Technical Analysis Functions: Comprehensive set of TA indicators and calculations
  • Mathematical Operations: Advanced mathematical functions and precision handling
  • Input Management: Flexible parameter and input handling system
  • Context Management: Maintains proper scoping and variable access rules
  • Runtime Transpilation: Converts PineTS code to executable JavaScript at runtime

Core Components

PineTS Class

The main class that handles:

  • Market data management
  • Series calculations
  • Built-in variables (open, high, low, close, volume, etc.)
  • Runtime execution context

Namespaces

  • Core: Essential Pine Script functionality and base operations
  • TechnicalAnalysis: Comprehensive set of technical indicators and analysis functions
  • PineMath: Mathematical operations and precision handling
  • Input: Parameter and input management system
  • Syminfo: Symbol information and market data helpers

Installation

npm install pinets

Usage Example

Converting Pine Script to PineTS

Original Pine Script:

/*==[ Original Pine Script ]==*/

//@version=5
indicator('My EMA Cross Strategy');

ema9 = ta.ema(close, 9);
ema18 = ta.ema(close, 18);

bull_bias = ema9 > ema18;
bear_bias = ema9 < ema18;

prev_close = close[1];
diff_close = close - prev_close;

_oo = open;
_oo = math.abs(open[1] - close[2]);
/*==[ Equivalent PineTS ]==*/

//
//'My EMA Cross Strategy';

let ema9 = ta.ema(close, 9);
let ema18 = ta.ema(close, 18);

let bull_bias = ema9 > ema18;
let bear_bias = ema9 < ema18;

let prev_close = close[1];
let diff_close = close - prev_close;

let _oo = open;
_oo = math.abs(open[1] - close[2]);

Running PineTS Code

import { PineTS, Provider } from 'pinets';

// Initialize with market data
const pineTS = new PineTS(Provider.Binance, 'BTCUSDT', 'D', 100);

// Run your indicator
const { result } = await pineTS.run((context) => {
    const { ta, math } = context;
    const { close, open } = context.data;

    let ema9 = ta.ema(close, 9);
    let ema18 = ta.ema(close, 18);

    let bull_bias = ema9 > ema18;
    let bear_bias = ema9 < ema18;

    let prev_close = close[1];
    let diff_close = close - prev_close;

    let _oo = open;
    _oo = math.abs(open[1] - close[2]);

    return { ema9, ema18, bull_bias, bear_bias };
});

📖 For detailed documentation on initialization options, parameters, and advanced usage, see the Initialization and Usage Guide

Key Differences from Pine Script

  1. Variable Declaration: Use JavaScript's const, let, and var instead of Pine Script's implicit declaration
  2. Function Syntax: JavaScript arrow functions and standard function syntax
  3. Module System: Pine Script native types should be imported using syntax like : const ta = context.ta; const {close, open} = context.data;
  4. Scoping Rules: Maintains Pine Script's series behavior through runtime transformation
  5. Return syntax: PineTS can returns an object with the results of the indicator, allowing you to get the results of the indicator in a single call.

Project Goals

PineTS aims for full coverage of Pine Script functions and capabilities. The ultimate goal is to enable running original Pine Script code directly without manual conversion to PineTS syntax.

  • Runtime Transpiler
  • Core Pine Script functions and variables
  • Series and scope management
  • Technical analysis functions
  • Mathematical functions
  • Input handling
  • Plots data handling
  • Market data connectors
  • Visualization add-ons
  • Strategy execution
  • Backtesting and simulation

Technical Details

The library uses a runtime transpiler that:

  1. Transforms PineTS code to handle time-series data
  2. Manages variable scoping and context
  3. Handles array indexing and series operations
  4. Provides Pine Script-compatible function calls

Contributing

Contributions are welcome! Please feel free to submit pull requests, create issues, or suggest improvements.

License

This project is open-source and available under the AGPL License.

Disclaimer

PineTS is an independent project and is not affiliated with, endorsed by, or associated with TradingView or Pine Script. All trademarks and registered trademarks mentioned belong to their respective owners.