TypeScript library for technical analysis of chart patterns, volume, and market structure
TypeScriptMIT
chart-patterns
TypeScript library that provides technical analysis for volume-based indicators and uses peak detection algorithms to generate pattern-based indicators.
Three-candle reversal pattern — bullish (morning) or bearish (evening).
Usage
import*astafrom'chart-patterns';import{IMarketProfile,ILocalRange,IZScoreConfig,IDivergence}from'chart-patterns/dist/types';import{MARKET_PROFILE_PERIODS,SIGNAL_DIRECTION}from'chart-patterns/dist/constants';// Market ProfileconstmarketProfiles: 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 profileconstvolumeProfileBarSession=ta.VolumeProfile.createBarSession({valueAreaRowSize: 24,valueAreaVolume: 0.7,pricePrecision: 2});// Process candles one by onecandles.forEach((candle)=>volumeProfileBarSession.processCandle(candle));// Get value area and distribution resultsconstvalueArea=barSession.getValueArea();constdistribution=barSession.getVolumeDistribution();// For raw trade data - even more precisionconstvolumeProfileTickSession=ta.VolumeProfile.createTickSession();// Process each individual tradefor(consttradeoftrades){volumeProfileTickSession.processTrade(trade);}// Get detailed trade analysis with exact price levelsconsttickDistribution=volumeProfileTickSession.getVolumeDistribution();// Money Flow Index - volume-based momentum oscillatorconstmfiValues=ta.MFI.calculateMFI(candles,14);// RSI and Stochastic RSIconstrsiValues=ta.RSI.calculateRSI(candles,14);conststochRsiResult=ta.RSI.calculateStochasticRSI(candles,14,14,3,3);// Z-Score configuration for peak/pattern detection algorithmsconstzScoreConfig: IZScoreConfig={lag: 2,// Controls smoothing and adaptability to trend changesthreshold: 0.1,// Number of standard deviations to classify a signalinfluence: 1// How strongly signals affect future calculations (0-1)};constranges: ILocalRange[]=ta.RangeBuilder.findRanges(candles,zScoreConfig);// Create zigzag points for pattern recognitionconstzigzags=ta.ZigZags.create(candles,zScoreConfig);constzScoreConfigDivergences: IZScoreConfig={lag: 3,threshold: 1,influence: 0.75};// Divergence Detection - Find divergences between price and indicatorsconstmfiDivergences: IDivergence[]=ta.Divergences.mfi(candles,zScoreConfigDivergences,14);constrsiDivergences: IDivergence[]=ta.Divergences.rsi(candles,zScoreConfigDivergences,14);// Candlestick Pattern Detection - Excess (large wicks indicating rejection)constexcessDirection: SIGNAL_DIRECTION=ta.CandlestickPatterns.getCandleExcessDirection(candles[0]);