GithubHelp home page GithubHelp logo

aarthiaradhana / technicalindicators Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anandanand84/technicalindicators

0.0 1.0 0.0 634 KB

A javascript technical indicators written in javascript

License: MIT License

JavaScript 43.30% HTML 1.19% TypeScript 55.52%

technicalindicators's Introduction

Travis CI

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});

Playground

Playground with code completion

Available Indicators

  1. Simple Moving Average (SMA).
  2. Exponential Moving Average (EMA).
  3. Weighted Moving Average (WMA).
  4. Moving Average Convergence Divergence (MACD).
  5. Bollinger Bands (BB).
  6. Average True Range (ATR).
  7. Relative Strength Index (RSI).
  8. Wilder’s Smoothing (Smoothed Moving Average, WEMA).
  9. Rate of Change (ROC).
  10. Know Sure Thing (KST).
  11. Stochastic Oscillator (KD).
  12. WilliamsR (W%R).
  13. Accumulation Distribution Line (ADL).
  14. On Balance Volume (OBV).
  15. Triple Exponentially Smoothed Average (TRIX).

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.

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.

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.

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.

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
  1. 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.
  2. Add the indicator to the index.js
  3. Run npm run build so it adds the indicator to the browser.js
  4. Add it to read me, with the link to the tonicdev url containing the sample.
  5. Add indicator it to keywords in package.json and bower.json
  6. Send a pull request.

Verify Documentation

node testdocs.js
http://localhost:5444/testdocs.html

technicalindicators's People

Contributors

anandanand84 avatar aarthiaradhana avatar chiu0602 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.