{"id":13394202,"url":"https://github.com/anandanand84/technicalindicators","last_synced_at":"2025-05-14T07:11:16.830Z","repository":{"id":39104935,"uuid":"57914774","full_name":"anandanand84/technicalindicators","owner":"anandanand84","description":"A javascript technical indicators written in typescript with pattern recognition right in the browser","archived":false,"fork":false,"pushed_at":"2022-11-03T08:42:59.000Z","size":22813,"stargazers_count":2288,"open_issues_count":86,"forks_count":572,"subscribers_count":97,"default_branch":"master","last_synced_at":"2025-05-11T03:27:26.768Z","etag":null,"topics":["candle-stick","candlestick-patterns-detection","cryptocurrency","head-and-shoulders","stock-data","stock-market","stock-trading","technical-analysis","technical-indicators"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anandanand84.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-02T19:16:32.000Z","updated_at":"2025-05-08T04:44:19.000Z","dependencies_parsed_at":"2022-07-14T10:31:24.263Z","dependency_job_id":null,"html_url":"https://github.com/anandanand84/technicalindicators","commit_stats":null,"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anandanand84%2Ftechnicalindicators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anandanand84%2Ftechnicalindicators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anandanand84%2Ftechnicalindicators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anandanand84%2Ftechnicalindicators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anandanand84","download_url":"https://codeload.github.com/anandanand84/technicalindicators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092798,"owners_count":22013292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["candle-stick","candlestick-patterns-detection","cryptocurrency","head-and-shoulders","stock-data","stock-market","stock-trading","technical-analysis","technical-indicators"],"created_at":"2024-07-30T17:01:12.310Z","updated_at":"2025-05-14T07:11:11.820Z","avatar_url":"https://github.com/anandanand84.png","language":"JavaScript","readme":"[![Travis CI](https://img.shields.io/travis/anandanand84/technicalindicators.svg?style=flat-square)](https://travis-ci.org/anandanand84/technicalindicators)\n\n# TechnicalIndicators\n\nA javascript technical indicators written in typescript.\n\n\n# Installation\n\n## Node.js versions \u003e= 10\n\n``` bash\nnpm install --save technicalindicators\n```\n\n``` javascript\nconst SMA = require('technicalindicators').SMA;\n```\n\n## Node.js versions \u003c 10\n\nFor nodejs version below 10 use 1.x versions of this library.\n\n## Webpack\n\nMake sure you have the following in your config file.\n\n``` javascript\nmodule.exports = {\n  resolve: {\n    mainFields: [\"module\", \"main\"]\n  }\n}\n\n```\n\n## Browser\n\nFor browsers install using npm, \n\nFor ES6 browsers use\n\n``` bash\nnpm install --save technicalindicators\n```\n\n```html\n\u003cscript src=\"node_modules/technicalindicators/dist/browser.es6.js\"\u003e\u003c/script\u003e\n```\n\nFor ES5 support it is necessary to include the babel-polyfill and respective file browser.js otherwise you will get an error. For example see [index.html](https://github.com/anandanand84/technicalindicators/blob/master/index.html \"index.html\")\n\n``` bash\nnpm install --save technicalindicators\nnpm install --save babel-polyfill\n```\n\n``` html\n\u003cscript src=\"node_modules/babel-polyfill/browser.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"node_modules/technicalindicators/dist/browser.js\"\u003e\u003c/script\u003e\n```\n\n### Pattern detection\n\nPattern detection is removed from version 3.0, if you need pattern detection use v2.0\n\nAll indicators will be available in window object. So you can just use\n\n``` javascript\nsma({period : 5, values : [1,2,3,4,5,6,7,8,9], reversedInput : true});\n```\n\nor\n\n``` javascript\nSMA.calculate({period : 5, values : [1,2,3,4,5,6,7,8,9]});\n```\n\n# Playground\n\n[Playground with code completion](http://anandanand84.github.io/technicalindicators/ \"Playground\")\n\n# Crypto Trading hub\n\nIf you like this project. You'll love my other project [crypto trading hub](https://cryptotrading-hub.com/?utm_source=github\u0026utm_medium=readme\u0026utm_campaign=technicalindicators \"Crypto trading hub\")\n\n1. Its free\n1. Realtime price charts \n1. Unified trading experience across exchanges\n1. Price alerts\n1. Realtime crypto screening using javascript (Find coins making high and low in realtime or anything you can write using this library and javascript in realtime)\n1. Trading from charts, \n1. Modify orders and ability to trade and create studies using javascript.\n\n![Home](/images/home.png)\n![Screener](/images/screener.png)\n![Trade](/images/trade.png)\n\n# Available Indicators\n\n1. [Accumulation Distribution Line (ADL)](https://tonicdev.com/anandaravindan/adl \"ADL\").\n1. [Average Directional Index (ADX)](https://github.com/anandanand84/technicalindicators/blob/master/test/directionalmovement/ADX.js \"ADX\").\n1. [Average True Range (ATR)](https://tonicdev.com/anandaravindan/atr \"ATR\").\n1. [Awesome Oscillator (AO)](https://github.com/anandanand84/technicalindicators/blob/master/test/oscillators/AwesomeOscillator.js \"AO\").\n1. [Bollinger Bands (BB)](https://tonicdev.com/anandaravindan/bb \"BB\").\n1. [Commodity Channel Index (CCI)](https://github.com/anandanand84/technicalindicators/blob/master/test/oscillators/CCI.js \"CCI\").\n1. [Force Index (FI)](https://github.com/anandanand84/technicalindicators/blob/master/test/volume/ForceIndex.js \"FI\").\n1. [Know Sure Thing (KST)](https://tonicdev.com/anandaravindan/kst \"KST\").\n1. [Moneyflow Index (MFI)](https://github.com/anandanand84/technicalindicators/blob/master/test/volume/MFI.js \"MFI\").\n1. [Moving Average Convergence Divergence (MACD)](https://tonicdev.com/anandaravindan/macd \"MACD\").\n1. [On Balance Volume (OBV)](https://tonicdev.com/anandaravindan/obv \"OBV\").\n1. [Parabolic Stop and Reverse (PSAR)](https://github.com/anandanand84/technicalindicators/blob/master/test/momentum/PSAR.js \"PSAR\").\n1. [Rate of Change (ROC)](https://tonicdev.com/anandaravindan/roc \"ROC\").\n1. [Relative Strength Index (RSI)](https://tonicdev.com/anandaravindan/rsi \"RSI\").\n1. [Simple Moving Average (SMA)](https://tonicdev.com/anandaravindan/sma \"SMA\").\n1. [Stochastic Oscillator (KD)](https://tonicdev.com/anandaravindan/stochastic \"KD\").\n1. [Stochastic RSI (StochRSI)](https://tonicdev.com/anandaravindan/stochasticrsi \"StochRSI\").\n1. [Triple Exponentially Smoothed Average (TRIX)](https://tonicdev.com/anandaravindan/trix \"TRIX\").\n1. [Typical Price](https://github.com/anandanand84/technicalindicators/blob/master/test/chart_types/TypicalPrice.js \"Typical Price\").\n1. [Volume Weighted Average Price (VWAP)](https://github.com/anandanand84/technicalindicators/blob/master/test/volume/VWAP.js \"VWAP\").\n1. [Volume Profile (VP)](https://github.com/anandanand84/technicalindicators/blob/master/test/volume/VolumeProfile.js \"VP\").\n1. [Exponential Moving Average (EMA)](https://tonicdev.com/anandaravindan/ema \"EMA\").\n1. [Weighted Moving Average (WMA)](https://tonicdev.com/anandaravindan/wma \"WMA\").\n1. [Wilder’s Smoothing (Smoothed Moving Average, WEMA)](https://tonicdev.com/anandaravindan/wema \"WEMA\").\n1. [WilliamsR (W%R)](https://tonicdev.com/anandaravindan/williamsr \"W%R\").\n1. [Ichimoku Cloud](https://github.com/anandanand84/technicalindicators/blob/master/test/ichimoku/IchimokuCloud.js \"Ichimoku Cloud\").\n\n# Other Utils\n\n1. [Average Gain](https://github.com/anandanand84/technicalindicators/blob/master/test/Utils/AverageGain.js \"\")\n1. [Average Loss](https://github.com/anandanand84/technicalindicators/blob/master/test/Utils/AverageLoss.js \"\")\n1. [Cross Up](https://github.com/anandanand84/technicalindicators/blob/master/test/Utils/CrossUp.js \"\")\n1. [Cross Down](https://github.com/anandanand84/technicalindicators/blob/master/test/Utils/CrossDown.js \"\")\n1. [Cross Over](https://github.com/anandanand84/technicalindicators/blob/master/test/Utils/CrossOver.js \"\")\n1. [Highest](https://github.com/anandanand84/technicalindicators/blob/master/test/Utils/Highest.js \"\")\n1. [Lowest](https://github.com/anandanand84/technicalindicators/blob/master/test/Utils/Lowest.js \"\")\n1. [Standard Deviation](https://github.com/anandanand84/technicalindicators/blob/master/test/Utils/SD.js \"\")\n1. [Sum](https://github.com/anandanand84/technicalindicators/blob/master/test/Utils/Sum.js \"\")\n\n\n# Chart Types\n\n1. [Renko (renko)](https://github.com/anandanand84/technicalindicators/blob/master/test/chart_types/Renko.js)\n1. [Heikin-Ashi (HA)](https://github.com/anandanand84/technicalindicators/blob/master/test/chart_types/HeikinAshi.js)\n\n\n# CandleStick Pattern\n\n1. [Abandoned Baby](https://runkit.com/anandaravindan/abandoned-baby).\n1. [Bearish Engulfing Pattern](https://runkit.com/aarthiaradhana/bearishengulfingpattern).\n1. [Bullish Engulfiing Pattern](https://runkit.com/aarthiaradhana/bullishengulfingpattern).\n1. [Dark Cloud Cover](https://runkit.com/aarthiaradhana/darkcloudcover).\n1. [Downside Tasuki Gap](https://runkit.com/aarthiaradhana/downsidetasukigap).\n1. [Doji](https://runkit.com/aarthiaradhana/doji).\n1. [DragonFly Doji](https://runkit.com/aarthiaradhana/dragonflydoji).\n1. [GraveStone Doji](https://runkit.com/aarthiaradhana/gravestonedoji).\n1. [BullishHarami](https://runkit.com/aarthiaradhana/bullishharami).\n1. [Bearish Harami Cross](https://runkit.com/aarthiaradhana/bearishharamicross).\n1. [Bullish Harami Cross](https://runkit.com/aarthiaradhana/bullishharamicross).\n1. [Bullish Marubozu](https://runkit.com/aarthiaradhana/bullishmarubozu).\n1. [Bearish Marubozu](https://runkit.com/aarthiaradhana/bearishmarubozu).\n1. [Evening Doji Star](https://runkit.com/aarthiaradhana/eveningdojistar).\n1. [Evening Star](https://runkit.com/aarthiaradhana/eveningstar).\n1. [Bearish Harami](https://runkit.com/aarthiaradhana/bearishharami).\n1. [Piercing Line](https://runkit.com/aarthiaradhana/piercingline).\n1. [Bullish Spinning Top](https://runkit.com/aarthiaradhana/bullishspinningtop).\n1. [Bearish Spinning Top](https://runkit.com/aarthiaradhana/bearishspinningtop).\n1. [Morning Doji Star](https://runkit.com/aarthiaradhana/morningdojistar).\n1. [Morning Star](https://runkit.com/aarthiaradhana/morningstar).\n1. [Three Black Crows](https://runkit.com/aarthiaradhana/threeblackcrows).\n1. [Three White Soldiers](https://runkit.com/aarthiaradhana/threewhitesoldiers).\n1. [Bullish Hammer](https://runkit.com/nerdacus/technicalindicator-bullishhammer).\n1. [Bearish Hammer](https://runkit.com/nerdacus/technicalindicator-bearishhammer).\n1. [Bullish Inverted Hammer](https://runkit.com/nerdacus/technicalindicator-bullishinvertedhammer).\n1. [Bearish Inverted Hammer](https://runkit.com/nerdacus/technicalindicator-bearishinvertedhammer).\n1. [Hammer Pattern](https://runkit.com/nerdacus/technicalindicator-hammerpattern).\n1. [Hammer Pattern (Unconfirmed)](https://runkit.com/nerdacus/technicalindicator-hammerpatternunconfirmed).\n1. [Hanging Man](https://runkit.com/nerdacus/technicalindicator-hangingman).\n1. [Hanging Man (Unconfirmed)](https://runkit.com/nerdacus/technicalindicator-hangingmanunconfirmed).\n1. [Shooting Star](https://runkit.com/nerdacus/technicalindicator-shootingstar).\n1. [Shooting Star (Unconfirmed)](https://runkit.com/nerdacus/technicalindicator-shootingstarunconfirmed).\n1. [Tweezer Top](https://runkit.com/nerdacus/technicalindicator-tweezertop).\n1. [Tweezer Bottom](https://runkit.com/nerdacus/technicalindicator-tweezerbottom).\n\nor\n\nSearch for all bullish or bearish using\n\n\n``` javascript\nvar twoDayBullishInput = {\n  open: [23.25,15.36],\n  high: [25.10,30.87],\n  close: [21.44,27.89],\n  low: [20.82,14.93],\n}\n\nvar bullish = require('technicalindicators').bullish;\n\nbullish(twoDayBullishInput) //true\n```\n\n\n# API\n\nThere are three ways you can use to get the indicator results.\n\n## calculate\n\nEvery indicator has a static method `calculate` which can be used to calculate the indicator without creating an object.\n\n``` javascript\nconst sma = require('technicalindicators').sma;\nvar prices = [1,2,3,4,5,6,7,8,9,10,12,13,15];\nvar period = 10;\nsma({period : period, values : prices})\n```\n\nor\n\n``` javascript\nconst SMA = require('technicalindicators').SMA;\nvar prices = [1,2,3,4,5,6,7,8,9,10,12,13,15];\nvar period = 10;\nSMA.calculate({period : period, values : prices})\n```\n\n## nextValue\n\n`nextValue` method is used to get the next indicator value.\n\n``` javascript\nvar sma = new SMA({period : period, values : []});\nvar results = [];\nprices.forEach(price =\u003e {\n  var result = sma.nextValue(price);\n  if(result)\n    results.push(result)\n});\n```\n\n## getResult\n\nThis a merge of calculate and nextValue. The usual use case would be\n\n1. Initialize indicator with available price value\n\n1. Get results for initialized values\n\n1. Use nextValue to get next indicator values for further tick.\n\n    ``` javascript\n    var sma = new SMA({period : period, values : prices});\n    sma.getResult(); // [5.5, 6.6, 7.7, 8.9]\n    sma.nextValue(16); // 10.1\n    ```\n\n    Note: Calling nextValue will not update getResult() value.\n\n### Precision\n\nThis 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.\n\n  ``` javascript\n  const technicalIndicators = require('technicalindicators');\n  technicalIndicators.setConfig('precision', 10);\n  ```\n\n\n# Contribute\n\nCreate 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.\n\n## Environment dependencies\n\nTypescript: Use typescript 2.0.0 other you might get max call stack reached error.\n\n``` npm install -g typescript@2.0.0 ```\n\nTechnicalIndicators depends on the [`canvas` package](https://npmjs.com/canvas), which requires some dependencies to be installed. You can find the instructions to do that [here](https://github.com/Automattic/node-canvas#installation). If you do not install these dependencies, expect to get this error message during the installation of TechnicalIndicators:\n\n```\n\u003e canvas@1.6.6 install /Users/balupton/Projects/trading/technicalindicators/node_modules/canvas\n\u003e node-gyp rebuild\n\n./util/has_lib.sh: line 31: pkg-config: command not found\ngyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in binding.gyp. while trying to load binding.gyp\n```\n\n## Setup\n\n``` bash\ngit clone git@github.com:anandanand84/technicalindicators.git  # or use your fork\ncd technicalindicators\nnpm run start\n```\n\n## Running tests and getting coverage\n\n``` bash\nnpm test\nnpm run cover\n```\n\n## Adding new indicators\n\n1. Add tests for the indicator and make them pass.  \n   (It would be better if a sample of the stockcharts excel is used for the test case.)\n1. Add the indicator to the `index.js` and `src/index.ts`\n1. Run build scripts: `npm run build-lib \u0026\u0026 npm run generateDts \u0026\u0026 npm run start`\n1. Add it to `README.md`, with the link to the runkit url containing the sample.\n1. Add indicator it to keywords in `package.json` and `bower.json`\n1. Send a Pull Request.\n\n\n## Verify Documentation\n\n``` bash\nnode testdocs.js\nopen \"http://localhost:5444/testdocs.html\"\n```\n\n\n# Donate\n1. XRB: `xrb_1shh8i77upiq4bjzi3ajik9ofq14bbcucshoapi3m7f8d74dc5k31o56yj5r`\n1. ETH: `0x0B56580Eb25f3F7e366dDA697161d314C17Bcb6a`\n1. LTC: `LLTUhKBRKs9sbW9F8MFQm7VVdZ1dJnXzGc`\n1. BTC: `1FGeJHoj7tjeLrm4JNtyPWTdBKPJjcqP6Y`\n1. BCH: `1AUFc8CEfHVjnoixbqTbX62WV8DZkpC1DU`\n","funding_links":[],"categories":["JavaScript","Technical analysis libraries","stock-market"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanandanand84%2Ftechnicalindicators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanandanand84%2Ftechnicalindicators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanandanand84%2Ftechnicalindicators/lists"}