Home

Awesome

trading-indicator

npm version

provide trading technical indicator values based on market data of almost crypto currency exchanges https://www.npmjs.com/package/trading-indicator

☕ Give me a coffee :heart:

Installation

Node.js version 10 or later is required

npm install --save trading-indicator

Fetch ticker information

let ticker = await indicators.ticker("binance", symbol, true)

The structure of a ticker is as follows:

{
    'symbol':        string symbol of the market ('BTC/USD', 'ETH/BTC', ...)
    'info':        { the original non-modified unparsed reply from exchange API },
    'timestamp':     int (64-bit Unix Timestamp in milliseconds since Epoch 1 Jan 1970)
    'datetime':      ISO8601 datetime string with milliseconds
    'high':          float, // highest price
    'low':           float, // lowest price
    'bid':           float, // current best bid (buy) price
    'bidVolume':     float, // current best bid (buy) amount (may be missing or undefined)
    'ask':           float, // current best ask (sell) price
    'askVolume':     float, // current best ask (sell) amount (may be missing or undefined)
    'vwap':          float, // volume weighed average price
    'open':          float, // opening price
    'close':         float, // price of last trade (closing price for current period)
    'last':          float, // same as `close`, duplicated for convenience
    'previousClose': float, // closing price for the previous period
    'change':        float, // absolute change, `last - open`
    'percentage':    float, // relative change, `(change/open) * 100`
    'average':       float, // average price, `(last + open) / 2`
    'baseVolume':    float, // volume of base currency traded for last 24 hours
    'quoteVolume':   float, // volume of quote currency traded for last 24 hours
}

Available Indicators

Available Alerts

Supported exchanges

Supported interval

Sample code

ATR (Average True Range)

  const { atr, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
  let atrData = await atr(14, "close", input)
  console.log(atrData[atrData.length - 1])

ADX (Average Directional Index)

  const { adx, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
  let adxData = await adx(14, "close", input)
  console.log(adxData[adxData.length - 1])

BB (Bollinger bands)

  const { bb, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
    let bbData = await bb(50, 2, "close", input)
    console.log(bbData[bbData.length - 2])

EMA (Exponential Moving Average)

  const { ema, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
  let emaData = await ema(8, "close", input)
  console.log(emaData[emaData.length - 1])

IchimokuCloud

  const { ichimokuCloud, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
  console.log(await ichimokuCloud(9, 26, 52, 26, input))

MACD (Moving Average Convergence Divergence)

  const { macd, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
    console.log(await macd(12, 26, 9, "close", input))

MFI

  const { mfi, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
   console.log(await mfi(14, input))

CCI

  const { cci, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
   console.log(await cci(14, input))

VWAP

  const { vwap, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
   console.log(await vwap(input))

OBV

  const { obv, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
   console.log(await obv(input))

RSI

  const { rsi, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
   console.log(await rsi(14, "close", input))

SMA (Simple Moving Average)

  const { sma, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
  let smaData = await sma(8, "close", input)
  console.log(smaData[smaData.length - 1])

Stochastic RSI

  const { stochasticRSI, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
   console.log(await stochasticRSI(3, 3, 14, 14, "close", input))

WMA (Weighted Moving Average)

  const { wma, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
  let wmaData = await wma(8, "close", input)
  console.log(wmaData[wmaData.length - 1])

KST

  const { kst, getDetachSourceFromOHLCV } = require('trading-indicator')
  const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
   console.log(await kst(input, 10, 15, 20, 30, 10, 10, 10, 15, 9))

Golden cross / Death cross

RSI in overBought/overSold area

Price crosses SMA/EMA

VWAP crosses SMA/EMA

KST crossing

Dependencies