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

chart-patterns

v1.0.26

Published

Trading Chart Patterns

Downloads

193

Readme

chart-patterns

npm version GitHub license

TypeScript library that provides technical analysis for volume-based indicators and uses peak detection algorithms to generate pattern-based indicators.

📊 Market & Volume Distribution

| Tool | Description | |------|-------------| | Market Profile | Generates TPO profiles with Value Area, Initial Balance, and Point of Control. | | Volume Profile | Generate Volume Profiles to find the Value Area. Process either Kline or tick data to build these profiles. |


🧭 Z-Score Tools for Ranges & Swings

| Tool | Description | |------|-------------| | Divergences | Detects bullish/bearish divergences between price and indicators (MFI, RSI). | | Peak Detector | Z-Score-based Peak Detector to find swing highs and lows. | | Range Finder | Finds key support and resistance zones from price swings. | | Zigzags | Highlights major price swings only. | | Zscore | Measures how far price deviates from the mean — useful for spotting extremes. |


🔍 Orderflow

Requires raw trade data. More information can be found in my blog post here.

| Tool | Description | |------|-------------| | Stacked Imbalances | Finds clusters of aggressive buying or selling — potential turning points. | | High Volume Node | Highlights price levels with exceptionally high traded volume. |


⚙️ General Indicators

| Tool | Description | |------|-------------| | EMA | Exponential Moving Average — a weighted moving average that reacts quickly to price. | | MFI | Money Flow Index — Volume-based oscillator showing buy/sell pressure. | | Pivot Points | Calculates pivot, support, and resistance levels. | | RSI | Relative Strength Index — Measures momentum to spot overbought/oversold. | | SMA | Simple Moving Average — Simple average of price over a period. | | Stochastic RSI | Tracks RSI momentum shifts. | | VWAP | Average price weighted by volume. |


🕯️ Candlestick Patterns

| Pattern | Description | |---------|-------------| | Doji | Signals indecision — open and close are nearly equal. | | Engulfing | Reversal pattern where one candle fully engulfs the previous. | | Excess | Detects large wicks, suggesting rejection from highs or lows. | | Harami | Small candle inside a larger one — potential reversal. | | Homing Pigeon | Two small-bodied candles in a downtrend — possible bullish reversal. | | Inverted Hammer | Small body with long upper wick — potential bullish reversal. | | Marubozu | Full-body candle with no wicks — strong directional move. | | Morning Star / Evening Star | Three-candle reversal pattern — bullish (morning) or bearish (evening). |

Usage

import * as ta from 'chart-patterns';
import { IMarketProfile, ILocalRange, IZScoreConfig, IDivergence } from 'chart-patterns/dist/types';
import { MARKET_PROFILE_PERIODS, SIGNAL_DIRECTION } from 'chart-patterns/dist/constants';

// Market Profile
const marketProfiles: IMarketProfile[] = ta.MarketProfile.build({
  candles,
  candleGroupingPeriod: MARKET_PROFILE_PERIODS.DAILY,
  tickSize: 0.1,
  pricePrecision: 2,
  tickMultiplier: 100,
  timezone: 'Europe/London'
});

// Volume Profile - Session-based API
// Create a session for candle-based volume profile
const volumeProfileBarSession = ta.VolumeProfile.createBarSession({
  valueAreaRowSize: 24,
  valueAreaVolume: 0.7,
  pricePrecision: 2
});

// Process candles one by one
candles.forEach((candle) => volumeProfileBarSession.processCandle(candle));

// Get value area and distribution results
const valueArea = barSession.getValueArea();
const distribution = barSession.getVolumeDistribution();

// For raw trade data - even more precision
const volumeProfileTickSession = ta.VolumeProfile.createTickSession();
// Process each individual trade
for (const trade of trades) {
  volumeProfileTickSession.processTrade(trade);
}
// Get detailed trade analysis with exact price levels
const tickDistribution = volumeProfileTickSession.getVolumeDistribution();

// Money Flow Index - volume-based momentum oscillator
const mfiValues = ta.MFI.calculateMFI(candles, 14);

// RSI and Stochastic RSI
const rsiValues = ta.RSI.calculateRSI(candles, 14);
const stochRsiResult = ta.RSI.calculateStochasticRSI(candles, 14, 14, 3, 3);

// Z-Score configuration for peak/pattern detection algorithms
const zScoreConfig: IZScoreConfig = {
  lag: 2,        // Controls smoothing and adaptability to trend changes
  threshold: 0.1, // Number of standard deviations to classify a signal
  influence: 1    // How strongly signals affect future calculations (0-1)
};

const ranges: ILocalRange[] = ta.RangeBuilder.findRanges(candles, zScoreConfig);

// Create zigzag points for pattern recognition
const zigzags = ta.ZigZags.create(candles, zScoreConfig);

const zScoreConfigDivergences: IZScoreConfig = {
  lag: 3,
  threshold: 1,
  influence: 0.75
};

// Divergence Detection - Find divergences between price and indicators
const mfiDivergences: IDivergence[] = ta.Divergences.mfi(candles, zScoreConfigDivergences, 14);
const rsiDivergences: IDivergence[] = ta.Divergences.rsi(candles, zScoreConfigDivergences, 14);

// Candlestick Pattern Detection - Excess (large wicks indicating rejection)
const excessDirection: SIGNAL_DIRECTION = ta.CandlestickPatterns.getCandleExcessDirection(candles[0]);

Visualisations