Package Exports
- technicalindicators
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (technicalindicators) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
TechnicalIndicators
A javascript technical indicators written in javascript.
Installation
For nodejs install using npm
npm install --save technicalindicators
const SMA = require('technicalindicators').SMA;
For browser install using bower
bower install --save technicalindicators
<script src="bower_components/technicalindicators/browser.js"></script>
All indicators will be available in window object. So you can just use
SMA.calculate({period : 5, values : [1,2,3,4,5,6,7,8,9]});
or
sma({period : 5, values : [1,2,3,4,5,6,7,8,9], reversedInput : true});
#Available Indicators
- Simple Moving Average (SMA).
- Exponential Moving Average (EMA).
- Weighted Moving Average (WMA).
- Moving Average Convergence Divergence (MACD).
- Bollinger Bands (BB).
- Average True Range (ATR).
- Relative Strength Index (RSI).
- Wilder’s Smoothing (Smoothed Moving Average, WEMA).
- Rate of Change (ROC).
- Know Sure Thing (KST).
- Stochastic Oscillator (KD).
- WilliamsR (W%R).
- Accumulation Distribution Line (ADL).
- On Balance Volume (OBV).
- Triple Exponentially Smoothed Average (TRIX).
#CandleStick Pattern
- Abandoned Baby.
- Bearish Engulfing Pattern.
- Bullish Engulfiing Pattern.
- Dark Cloud Cover.
- Downside Tasuki Gap.
- Doji.
- DragonFly Doji.
- GraveStone Doji.
- BullishHarami.
- Bearish Harami Cross.
- Bullish Harami Cross.
- Bullish Marubozu.
- Bearish Marubozu.
- Evening Doji Star.
- Evening Star.
- Bearish Harami.
- Piercing Line.
- Bullish Spinning Top.
- Bearish Spinning Top.
- Morning Doji Star.
- Morning Star.
- Three Black Crows.
- Three White Soldiers.
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.hasPattern(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.
```javascript
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
```nextValue``` method is used to get the next indicator value.
```javascript
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.
```javascript
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.
#Running tests and getting coverage
```
npm test
```
```
npm run cover
```
# 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.
## Adding new indicators.
1. Fork the project, clone it, run
```
npm install
```
```
gulp watch-test
```
2. Add tests for the indicator. Make it pass. It would be better if a sample of the stockcharts excel is used for the test case.
3. Add the indicator to the index.js
4. Run ```npm run build``` so it adds the indicator to the browser.js
5. Add it to read me, with the link to the tonicdev url containing the sample.
6. Add indicator it to keywords in package.json and bower.json
7. Send a pull request.