Technical indicators for systematic trading. 37 functions covering trend, momentum, volatility, volume, oscillators, and chart patterns. Zero dependencies, pure functions, written in plain JS.
Battle-tested in a production multi-strategy trading framework where these indicators run a live fleet across crypto and equities.
npm install @stratchai/indicatorsimport {
calcBollingerBands,
calcRSI,
calcADX,
calcSupertrend,
calcMACD,
} from "@stratchai/indicators";
const closes: number[] = [/* ... daily closes ... */];
const highs: number[] = [/* ... daily highs ... */];
const lows: number[] = [/* ... daily lows ... */];
const bb = calcBollingerBands(closes, 20, 2);
// Inferred: { middle: number; upper: number; lower: number; std: number } | null
const rsi = calcRSI(closes, 14);
// Inferred: number | null
const adx = calcADX(highs, lows, closes, 14);
// Inferred: { value, diPlus, diMinus, trending, bullish, ... } | nullconst { calcBollingerBands, calcRSI, calcADX } = require("@stratchai/indicators");
const bb = calcBollingerBands(closes, 20, 2);
const rsi = calcRSI(closes, 14);
const adx = calcADX(highs, lows, closes, 14);Every function is typed — your IDE autocompletes the parameter list, infers the return shape, and surfaces the | null cases at the point of use.
calcSMA(prices, period)— Simple moving averagecalcEMA(prices, period)— Exponential moving averagecalcMACD(prices, fast, slow, signal)— Moving Average Convergence DivergencecalcADX(highs, lows, closes, period)— Average Directional Index (Wilder)calcSupertrend(highs, lows, closes, period, mult)— Supertrend (ATR-based trailing band)calcParabolicSAR(highs, lows, closes, afStep, afMax)— Parabolic SAR (Wilder)calcAlligator(prices, jaw, teeth, lips)— Williams AlligatorcalcAwesomeOscillator(highs, lows, fast, slow)— Bill Williams Awesome OscillatorcalcROC(prices, period)— Rate of ChangecalcHMA(prices, period)— Hull Moving AveragecalcIchimoku(highs, lows, closes, ...)— Ichimoku CloudcalcTrendStructure(closes, highs, lows, opts)— HH/HL trend structure analyzercalc52WeekHighLow(closes, highs, lows)— Rolling 52-week extremes
calcBollingerBands(prices, period, k)— Bollinger Bands (J. Bollinger)calcATR(highs, lows, closes, period)— Average True RangecalcATRExpansion(highs, lows, closes, period)— ATR + expansion ratiocalcKeltner(highs, lows, closes, period, mult, atrPeriod)— Keltner ChannelscalcDonchian(highs, lows, period)— Donchian Channels (Turtle Trading)calcMassIndex(highs, lows, period, sumPeriod, bulgeLookback)— Mass Index (reversal pattern)
calcOBV(closes, volumes, smaPeriod)— On-Balance VolumecalcMFI(highs, lows, closes, volumes, period)— Money Flow IndexcalcCMF(highs, lows, closes, volumes, period)— Chaikin Money FlowcalcVWAP(closes, highs, lows, timestamps, params)— Volume-Weighted Average Price
calcRSI(prices, period)— Relative Strength Index (Wilder)calcStochastic(highs, lows, closes, period)— Stochastic %KcalcAroon(highs, lows, period)— Aroon Up/Down/OscillatorcalcVolIndex(prices, k)— In-house volatility index
calcHammer(opens, highs, lows, closes, opts)— Hammer candlecalcEngulfing(opens, highs, lows, closes, opts)— Bullish/Bearish EngulfingcalcMorningStar(opens, highs, lows, closes, opts)— Morning Star reversalcalcDoubleBottom(closes, highs, lows, opts)— Double BottomcalcCupAndHandle(closes, highs, lows, opts)— Cup & Handle (Bulkowski)calcFlagPattern(closes, highs, lows, opts, volumes)— Flag breakoutcalcCandlePattern(opens, highs, lows, closes, params)— 2-candle bullish impulsecalcAscendingTriangle(closes, highs, lows, opts)— Ascending Triangle
calcPivotPoints(high, low, close)— Floor pivot pointscalcFibonacci(high, low)— Fibonacci retracements
Array order. All inputs are arrays in chronological order — oldest at index 0, most recent at the end. The function reads the most recent values (e.g., prices[prices.length - 1] is the current bar's close).
Return shape. Most indicators return null when there aren't enough bars to compute (e.g., calcRSI(prices, 14) returns null when prices.length < 15). Composite indicators return objects with named fields ({ value, bullish, expansion, ... }) — see jsdoc or just console.log the return.
No I/O. Every function is pure: given the same inputs, returns the same output. No filesystem, no network, no time dependency. Easy to test, easy to compose.
Most existing JS indicator libraries are either old/unmaintained, thin C bindings with platform pain, or return raw numbers without the richer context strategies actually need ({ value, bullish, expansion }-shaped returns instead of just a number). Several useful patterns — Cup & Handle, Flag, Ascending Triangle, Morning Star — are missing from most libraries entirely.
This library was built to fill three specific gaps:
- Boolean conveniences (
adx.trending,supertrend.bullish,band.aboveUpper) — most libraries return raw numbers, leaving the threshold logic to every consumer - Pattern detectors that match technical-analysis literature (Bulkowski, Wilder, Bollinger) — Cup & Handle, Flag, Ascending Triangle, Morning Star
- No external dependencies — works in any Node.js environment, no native compilation, no C bindings
MIT