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 🙏

© 2026 – Pkg Stats / Ryan Hefner

trading-signals

v8.2.0

Published

Technical indicators to run technical analysis with JavaScript / TypeScript.

Downloads

76,204

Readme

Trading Signals

Language Details Code Coverage License Package Version

Technical indicators and overlays to run technical analysis with JavaScript / TypeScript.

Motivation

The "trading-signals" library provides a TypeScript implementation for common technical indicators. It is well-suited for algorithmic trading, allowing developers to perform signal computations for automated trading strategies.

Financial trading does not require Python or C, so the goal here is to provide renowned technical indicators in TypeScript. Results are checked against reference data like Tulip Indicators.

All indicators can be updated over time by streaming data (prices or candles) to the add method. Some indicators also provide static batch methods for further performance improvements when providing data up-front during a backtest or historical data import. You can try it out streaming input data by running the provided demo script with npm start, which uses a keyboard input stream.

Features

  • Streaming Updates: No need to reprocess historical data
  • Replace Mode: Efficient live chart updates
  • Lazy Evaluation: Indicators only calculate when stable
  • Memory Efficiency: Rolling windows, not full history storage
  • Excellent Test Coverage: 100% across all metrics
  • Zero Runtime Dependencies: Minimal bundle size
  • Type Safety: Full TypeScript with strict mode

Supported Technical Indicators

  1. Acceleration Bands (ABANDS)
  2. Accelerator Oscillator (AC)
  3. Accumulation/Distribution (AD)
  4. Aroon (AROON)
  5. Average Directional Index (ADX)
  6. Average True Range (ATR)
  7. Awesome Oscillator (AO)
  8. Bollinger Bands (BBANDS)
  9. Bollinger Bands Width (BBW)
  10. Center of Gravity (CG)
  11. Chaikin Money Flow (CMF)
  12. Chaikin Oscillator (ADOSC)
  13. Chande Momentum Oscillator (CMO)
  14. Chandelier Exit (CE)
  15. Commodity Channel Index (CCI)
  16. Directional Movement Index (DMI / DX)
  17. Double Exponential Moving Average (DEMA)
  18. Dual Moving Average (DMA)
  19. Ease of Movement (EMV)
  20. Exponential Moving Average (EMA)
  21. Efficiency Ratio (ER)
  22. Hull Moving Average (HMA)
  23. Interquartile Range (IQR)
  24. Kaufman's Adaptive Moving Average (KAMA)
  25. Linear Regression (LINREG)
  26. Mean Absolute Deviation (MAD)
  27. Momentum (MOM / MTM)
  28. Money Flow Index (MFI)
  29. Moving Average Convergence Divergence (MACD)
  30. Normalized Average True Range (NATR)
  31. On-Balance Volume (OBV)
  32. Parabolic SAR (PSAR)
  33. Percentage Price Oscillator (PPO)
  34. Price Volume Trend (PVT)
  35. Range Expansion Index (REI)
  36. Rate-of-Change (ROC)
  37. Relative Moving Average (RMA)
  38. Relative Strength Index (RSI)
  39. Relative Volume (RVOL)
  40. Simple Moving Average (SMA)
  41. Spencer's 15-Point Moving Average (SMA15)
  42. Stochastic Oscillator (STOCH)
  43. Stochastic RSI (STOCHRSI)
  44. SuperTrend (SUPERTREND)
  45. Tom Demark's Sequential Indicator (TDS)
  46. Triple Exponential Moving Average (TEMA)
  47. Triple Smoothed EMA Rate of Change (TRIX)
  48. True Range (TR)
  49. Ultimate Oscillator (ULTOSC)
  50. Volatility Stop (VSTOP)
  51. Volume Rate of Change (VROC)
  52. Volume-Weighted Average Price (VWAP)
  53. Volume Weighted Moving Average (VWMA)
  54. Weighted Moving Average (WMA)
  55. Wilder's Smoothed Moving Average (WSMA / WWS / SMMA / MEMA)
  56. Williams %R (WILLR)
  57. Zig Zag Indicator (ZigZag)

Utility Methods:

  1. Average / Mean
  2. Grid Sizing (for grid trading bots)
  3. Maximum
  4. Median
  5. Minimum
  6. Quartile
  7. Standard Deviation
  8. Streaks
  9. Weekday

Installation

npm install trading-signals

Usage

The library is published as ESM:

import {SMA} from 'trading-signals';

CommonJS projects can load it via require(esm) on Node.js 20.19+:

const {SMA} = require('trading-signals');

Example:

import {SMA} from 'trading-signals';

const sma = new SMA(3);

// You can add values individually:
sma.add(40);
sma.add(30);
sma.add(20);

// You can add multiple values at once:
sma.updates([20, 40, 80]);

// You can replace a previous value (useful for live charting):
sma.replace(40);

// You can check if an indicator is stable:
console.log(sma.isStable); // true

// You can read the result as "number | null", which is null until the indicator is stable:
console.log(sma.getResult()); // 50.0003

// Or you can read it as "number" and let it throw while the indicator is not stable yet:
console.log(sma.getResultOrThrow()); // 50.0003

// Various precisions are available too:
console.log(sma.getResultOrThrow().toFixed(2)); // "50.00"
console.log(sma.getResultOrThrow().toFixed(4)); // "50.0003"

// Each indicator also includes convenient features such as "lowest" and "highest" lifetime values:
console.log(sma.lowest?.toFixed(2)); // "23.33"
console.log(sma.highest?.toFixed(2)); // "53.33"

Technical Indicator Types

Indicator Function

  • Momentum indicators: Measure the speed and strength (intensity) of price movements in a particular direction (overbought/oversold)
  • Trend indicators: Measure the direction of a trend (bullish/bearish)
  • Volatility indicators: Measure the degree of variation in prices over time, regardless of direction
  • Volume indicators: Measure the strength of a trend based on volume

Key readings:

  • Bullish sentiment: expect prices to rise
  • Bearish sentiment: expect prices to fall
  • Overbought condition: price may have risen too much too fast, meaning it’s trending up, but traders expect a short-term dip before continuing higher
  • Oversold condition: price may have dropped too much too fast, meaning it’s trending down, but traders expect a short-term bounce before continuing lower or reversing upward

Indicator Timing

  • Leading Indicators: Predictive tools that try to signal future price movements before they happen (i.e. RSI, Stochastic Oscillator, Volume spikes)
  • Lagging Indicators: Confirmative tools that signal after a trend or move has already started (i.e. Moving Averages, MACD, ADX)

Indicator Scale

  • Indicators: Have no upper or lower limits
  • Oscillators: Move within a fixed range (e.g. 0-100, –1 to +1)

Alternatives

Maintainers

Benny Neugebauer on Stack Exchange

License

This project is MIT licensed.