deno-talib

A javascript technical indicators written in typescript for deno.

alt text

Installation

Deno

deno install https://deno.land/x/talib
import { SMA } from 'https://deno.land/x/talib';

# or specific version 

import { SMA } from 'https://deno.land/x/talib@0.0.3';

Pattern detection

All indicators will be available in window object. So you can just use

sma({ period: 5, values: [1,2,3,4,5,6,7,8,9], reversedInput: true});

or

SMA.calculate({ period: 5, values: [1,2,3,4,5,6,7,8,9] });

Available Indicators

  1. Accumulation Distribution Line (ADL).
  2. Average Directional Index (ADX).
  3. Average True Range (ATR).
  4. Awesome Oscillator (AO).
  5. Bollinger Bands (BB).
  6. Commodity Channel Index (CCI).
  7. Force Index (FI).
  8. Know Sure Thing (KST).
  9. Moneyflow Index (MFI).
  10. Moving Average Convergence Divergence (MACD).
  11. On Balance Volume (OBV).
  12. Parabolic Stop and Reverse (PSAR).
  13. Rate of Change (ROC).
  14. Relative Strength Index (RSI).
  15. Simple Moving Average (SMA).
  16. Stochastic Oscillator (KD).
  17. Stochastic RSI (StochRSI).
  18. Triple Exponentially Smoothed Average (TRIX).
  19. Typical Price.
  20. Volume Weighted Average Price (VWAP).
  21. Volume Profile (VP).
  22. Exponential Moving Average (EMA).
  23. Weighted Moving Average (WMA).
  24. Wilder’s Smoothing (Smoothed Moving Average, WEMA).
  25. WilliamsR (W%R).
  26. Ichimoku Cloud.

Other Utils

  1. Average Gain
  2. Average Loss
  3. Cross Up
  4. Cross Down
  5. Cross Over
  6. Highest
  7. Lowest
  8. Standard Deviation
  9. Sum

Chart Types

  1. Renko (renko)
  2. Heikin-Ashi (HA)

CandleStick Pattern

  1. Abandoned Baby.
  2. Bearish Engulfing Pattern.
  3. Bullish Engulfiing Pattern.
  4. Dark Cloud Cover.
  5. Downside Tasuki Gap.
  6. Doji.
  7. DragonFly Doji.
  8. GraveStone Doji.
  9. BullishHarami.
  10. Bearish Harami Cross.
  11. Bullish Harami Cross.
  12. Bullish Marubozu.
  13. Bearish Marubozu.
  14. Evening Doji Star.
  15. Evening Star.
  16. Bearish Harami.
  17. Piercing Line.
  18. Bullish Spinning Top.
  19. Bearish Spinning Top.
  20. Morning Doji Star.
  21. Morning Star.
  22. Three Black Crows.
  23. Three White Soldiers.
  24. Bullish Hammer.
  25. Bearish Hammer.
  26. Bullish Inverted Hammer.
  27. Bearish Inverted Hammer.
  28. Hammer Pattern.
  29. Hammer Pattern (Unconfirmed).
  30. Hanging Man.
  31. Hanging Man (Unconfirmed).
  32. Shooting Star.
  33. Shooting Star (Unconfirmed).
  34. Tweezer Top.
  35. Tweezer Bottom.

or

Search for all bullish or bearish using

import { bullish } from 'https://deno.land/x/talib';

const twoDayBullishInput = {
  open: [23.25,15.36],
  high: [25.10,30.87],
  close: [21.44,27.89],
  low: [20.82,14.93],
}

bullish(twoDayBullishInput) //true

API

There are three ways you can use to get the indicator results.

calculate

Every indicator has a static method calculate which can be used to calculate the indicator without creating an object.

import { SMA } from 'https://deno.land/x/talib';
var prices = [1,2,3,4,5,6,7,8,9,10,12,13,15];
var period = 10;
sma({period : period, values : prices})

or

import { SMA } from 'https://deno.land/x/talib';
var prices = [1,2,3,4,5,6,7,8,9,10,12,13,15];
var period = 10;
SMA.calculate({period : period, values : prices})

nextValue

nextValue method is used to get the next indicator value.

var sma = new SMA({period : period, values : []});
var results = [];
prices.forEach(price => {
  var result = sma.nextValue(price);
  if(result)
    results.push(result)
});

getResult

This a merge of calculate and nextValue. The usual use case would be

  1. Initialize indicator with available price value

  2. Get results for initialized values

  3. Use nextValue to get next indicator values for further tick.

    var sma = new SMA({period : period, values : prices});
    sma.getResult(); // [5.5, 6.6, 7.7, 8.9]
    sma.nextValue(16); // 10.1

    Note: Calling nextValue will not update getResult() value.

Precision

This uses regular javascript numbers, so there can be rounding errors which are negligible for a technical indicators, you can set precision by using the below config. By default there is no precision set.

import talib from 'https://deno.land/x/talib';
talib.setConfig('precision', 10);

Contribute

Create issues about anything you want to report, change of API’s, or request for adding new indicators. You can also create pull request with new indicators.

Thanks

Original node package is from anandanand84. Thanks to https://github.com/anandanand84/technicalindicators