Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
technicalindicators
Advanced tools
Techincal Indicators written in javascript
Weekly downloads
Readme
A javascript technical indicators written in typescript.
npm install --save technicalindicators
const SMA = require('technicalindicators').SMA;
For nodejs version below 10 use 1.x versions of this library.
Make sure you have the following in your config file.
module.exports = {
resolve: {
mainFields: ["module", "main"]
}
}
For browsers install using npm,
For ES6 browsers use
npm install --save technicalindicators
<script src="node_modules/technicalindicators/dist/browser.es6.js"></script>
For 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
npm install --save technicalindicators
npm install --save babel-polyfill
<script src="node_modules/babel-polyfill/browser.js"></script>
<script src="node_modules/technicalindicators/dist/browser.js"></script>
Pattern detection is removed from version 3.0, if you need pattern detection use v2.0
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]});
Playground with code completion
If you like this project. You'll love my other project crypto trading hub
or
Search for all bullish or bearish using
var twoDayBullishInput = {
open: [23.25,15.36],
high: [25.10,30.87],
close: [21.44,27.89],
low: [20.82,14.93],
}
var bullish = require('technicalindicators').bullish;
bullish(twoDayBullishInput) //true
There are three ways you can use to get the indicator results.
Every indicator has a static method calculate
which can be used to calculate the indicator without creating an object.
const sma = require('technicalindicators').sma;
var prices = [1,2,3,4,5,6,7,8,9,10,12,13,15];
var period = 10;
sma({period : period, values : prices})
or
const SMA = require('technicalindicators').SMA;
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
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)
});
This a merge of calculate and nextValue. The usual use case would be
Initialize indicator with available price value
Get results for initialized values
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.
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.
const technicalIndicators = require('technicalindicators');
technicalIndicators.setConfig('precision', 10);
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.
Typescript: Use typescript 2.0.0 other you might get max call stack reached error.
npm install -g typescript@2.0.0
TechnicalIndicators depends on the canvas
package, which requires some dependencies to be installed. You can find the instructions to do that here. If you do not install these dependencies, expect to get this error message during the installation of TechnicalIndicators:
> canvas@1.6.6 install /Users/balupton/Projects/trading/technicalindicators/node_modules/canvas
> node-gyp rebuild
./util/has_lib.sh: line 31: pkg-config: command not found
gyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
git clone git@github.com:anandanand84/technicalindicators.git # or use your fork
cd technicalindicators
npm run start
npm test
npm run cover
index.js
and src/index.ts
npm run build-lib && npm run generateDts && npm run start
README.md
, with the link to the runkit url containing the sample.package.json
and bower.json
node testdocs.js
open "http://localhost:5444/testdocs.html"
xrb_1shh8i77upiq4bjzi3ajik9ofq14bbcucshoapi3m7f8d74dc5k31o56yj5r
0x0B56580Eb25f3F7e366dDA697161d314C17Bcb6a
LLTUhKBRKs9sbW9F8MFQm7VVdZ1dJnXzGc
1FGeJHoj7tjeLrm4JNtyPWTdBKPJjcqP6Y
1AUFc8CEfHVjnoixbqTbX62WV8DZkpC1DU
FAQs
Techincal Indicators written in javascript
The npm package technicalindicators receives a total of 3,066 weekly downloads. As such, technicalindicators popularity was classified as popular.
We found that technicalindicators demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.