Giter VIP home page Giter VIP logo

anandanand84 / technicalindicators Goto Github PK

View Code? Open in Web Editor NEW
2.1K 96.0 556.0 22.28 MB

A javascript technical indicators written in typescript with pattern recognition right in the browser

License: MIT License

JavaScript 64.88% HTML 1.33% TypeScript 33.62% Shell 0.14% Dockerfile 0.03%
cryptocurrency stock-market stock-trading technical-indicators technical-analysis candle-stick candlestick-patterns-detection stock-data head-and-shoulders

technicalindicators's Introduction

Travis CI

TechnicalIndicators

A javascript technical indicators written in typescript.

Installation

Node.js versions >= 10

npm install --save technicalindicators
const SMA = require('technicalindicators').SMA;

Node.js versions < 10

For nodejs version below 10 use 1.x versions of this library.

Webpack

Make sure you have the following in your config file.

module.exports = {
  resolve: {
    mainFields: ["module", "main"]
  }
}

Browser

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

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

Playground with code completion

Crypto Trading hub

If you like this project. You'll love my other project crypto trading hub

  1. Its free
  2. Realtime price charts
  3. Unified trading experience across exchanges
  4. Price alerts
  5. 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)
  6. Trading from charts,
  7. Modify orders and ability to trade and create studies using javascript.

Home Screener Trade

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

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

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({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

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.

const technicalIndicators = require('technicalindicators');
technicalIndicators.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.

Environment dependencies

Typescript: Use typescript 2.0.0 other you might get max call stack reached error.

npm install -g [email protected]

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:

> [email protected] 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

Setup

git clone [email protected]:anandanand84/technicalindicators.git  # or use your fork
cd technicalindicators
npm run start

Running tests and getting coverage

npm test
npm run cover

Adding new indicators

  1. Add tests for the indicator and make them 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 and src/index.ts
  3. Run build scripts: npm run build-lib && npm run generateDts && npm run start
  4. Add it to README.md, with the link to the runkit 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
open "http://localhost:5444/testdocs.html"

Donate

  1. XRB: xrb_1shh8i77upiq4bjzi3ajik9ofq14bbcucshoapi3m7f8d74dc5k31o56yj5r
  2. ETH: 0x0B56580Eb25f3F7e366dDA697161d314C17Bcb6a
  3. LTC: LLTUhKBRKs9sbW9F8MFQm7VVdZ1dJnXzGc
  4. BTC: 1FGeJHoj7tjeLrm4JNtyPWTdBKPJjcqP6Y
  5. BCH: 1AUFc8CEfHVjnoixbqTbX62WV8DZkpC1DU

technicalindicators's People

Contributors

aarthiaradhana avatar anandanand84 avatar balupton avatar chiu0602 avatar cwouter avatar davydof avatar epicallan avatar fireveined avatar hariseldon78 avatar jmoli avatar lteacher avatar marcus-n3rd avatar minhphuc429 avatar namefilip avatar tetradeca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

technicalindicators's Issues

Using the latest data instead the first of the array

In the logic of the Candlestickfinders you are using the first element of the data, instead the latest, example;
https://github.com/anandanand84/technicalindicators/blob/master/src/candlestick/MorningStar.ts#L10

I think i shoul look something like;


logic (data:StockData) {
    const firstDay = data.length - 3;
    const secondDay = data.length - 2;
    const thirdDay = data.length - 1;

    let firstdaysOpen   = data.open[firstDay];
    let firstdaysClose  = data.close[firstDay];
    let firstdaysHigh   = data.high[firstDay];
    let firstdaysLow    = data.low[firstDay]
    let seconddaysOpen  = data.open[secondDay];
    let seconddaysClose = data.close[secondDay];
    let seconddaysHigh  = data.high[secondDay];
    let seconddaysLow   = data.low[secondDay]
    let thirddaysOpen   = data.open[thirdDay];
    let thirddaysClose  = data.close[thirdDay];
    let thirddaysHigh   = data.high[thirdDay];
    let thirddaysLow    = data.low[thirdDay];
     

Trouble using CCI

Hi, thanks for this awesome library. You rock!

Having trouble getting CCI working in the latest release 10.0.16
const CCI = require('technicalindicators').CCI;
TypeError: Cannot read property 'calculate' of undefined

const CCI = require('technicalindicators/lib/oscillators/CCI').CCI;
(function (exports, require, module, __filename, __dirname) { import { Indicator, IndicatorInput } from '../indicator/indicator';
^^^^^^
SyntaxError: Unexpected token import

Thanks in advance!!

Cannot load some indicators in newer versions

I am seeing issues with a number of the candlestick patterns in newer versions with error

Cannot read property 'hasPattern' of undefined

For example:

let doji = require('technicalindicators').Doji
let values = ...
doji.hasPattern(values)

The above will throw the error and I am seeing this across a number of patterns, not just Doji. The last version available on npm that seems stable is 0.2.17.

Reversing Inputs

Love the library! Thanks for all the hard work! I am trying to understand if I should be reversing my Inputs or not, and was hoping to get some clarification on what I should be understanding! Thanks again!

Stochastic

export function stochastic(input:StochasticInput):StochasticOutput[] {
    Indicator.reverseInputs(input); //First Reverse Input Check
    var result = new Stochastic(input).result;
    if(input.reversedInput) { //Reversed Input Boolean 
        result.reverse();  //Reversed Result
    }
    Indicator.reverseInputs(input); //Second Reverse Input Check After Input is Reversed
    return result;
};

And in the Indicator Class

 static reverseInputs(input:any):void {
    if(input.reversedInput) { //Same Reversed Input Boolean Check
        input.values ? input.values.reverse() : undefined;
        input.open ? input.open.reverse() : undefined;
        input.high ? input.high.reverse() : undefined;
        input.low ? input.low.reverse() : undefined;
        input.close ? input.close.reverse() : undefined;
        input.volume ? input.volume.reverse() : undefined;
        input.timestamp ? input.timestamp.reverse() : undefined;
    }
}

As far as I can tell unless the reverseInput = truenothing happens. So when reverseInputs = true is the input being reversed twice? and the output reversed once? Is the input being reversed after the result is reversed and does that matter or just redundant? Sorry if I am missing something. Cheers!

variable "strategy" is not defined in CandlestickFinder.js

Here is the stack trace:

ReferenceError: strategy is not defined
    at AbandonedBaby._getLastDataForCandleStick (...\node_modules\technicalindicators\lib\candlestick\CandlestickFinder.js:51:75)
    at AbandonedBaby.hasPattern (...\node_modules\technicalindicators\lib\candlestick\CandlestickFinder.js:45:43)
...
...

Chart pattern

Any chance that we can add the like of Double bottom, Rising wedge, Double top, Head and shoulder, ... ?

TypeError: Cannot read property 'toFixed' of undefined

When using the MACD function getting this error here is the stack trace

TypeError: Cannot read property 'toFixed' of undefined at format (node_modules/technicalindicators/lib/Utils/NumberFormatter.js:4:24) at node_modules/technicalindicators/lib/moving_averages/MACD.js:52:27 at next (native) at MACD.input.values.forEach (node_modules/technicalindicators/lib/moving_averages/MACD.js:62:41) at Array.forEach (native) at MACD (node_modules/technicalindicators/lib/moving_averages/MACD.js:61:22) at Function.macd [as calculate] (node_modules/technicalindicators/lib/moving_averages/MACD.js:78:18)

portions of the file path were removed, verified the data is coming in in the right format

Bullish vs Bearish indicators not checking Open vs Close

For instance, bearishspinningtop returns true for the following data

low: [205],
high: [207.95],
open: [206.16],
close: [207.9],
volume: [5231.61]

I noticed a couple things in the following code:

let bodyLength           = Math.abs(daysClose-daysOpen); // this is good
let upperShadowLength    = Math.abs(daysHigh-daysOpen); // this should be daysHigh - Math.max(daysOpen, daysClose)
let lowerShadowLength    = Math.abs(daysHigh-daysLow); // this should be Math.min(daysOpen,days.close) - daysLow
let isBearishSpinningTop = bodyLength < upperShadowLength &&
  bodyLength < lowerShadowLength; // this should include check for daysClose < daysOpen
  1. it wasn't explicitly checking if open < close (definition of bearish in this case)
  2. the shadow calculations were off (comments in code above)

Would you like me to start a PR to go through and fix these? I'm very interested in getting all these working for my project and would prefer to contribute to your lib rather than fork to correct.

Nesting indicators into window object is incompatible with previous versions.

package.json

"dependencies":  {
   "technicalindicators": "^1.0.3"
}

code example based on my usage from a previous version of this (super cool) library.

import * as Indicators from 'technicalindicators';

console.log(Indicators['SMA'])
// undefined 

console.log(Indicatos)
// window { ... }

console.log(Indicatos.window['SMA'])
// function...

I think this is due to versioning semantics. It seems version 1.0.21 is getting installed but version 1.0.3 is the last compatible version with the code example.

$ npm view technicalindicators
     '1.0.0': '2017-05-12T17:23:34.006Z',
     '1.0.1': '2017-05-16T18:53:57.903Z',
     '1.0.3': '2017-06-19T12:18:40.570Z',
     '1.0.4': '2017-06-21T14:50:55.925Z',
     '1.0.5': '2017-07-02T01:20:31.064Z',
     '1.0.6': '2017-07-25T14:23:36.998Z',
     '1.0.7': '2017-07-25T21:10:11.446Z',
     '1.0.8': '2017-07-26T15:23:42.035Z',
     '1.0.9': '2017-07-26T17:48:50.302Z',
     '1.0.10': '2017-07-26T20:01:53.177Z',
     '1.0.11': '2017-07-26T21:20:13.597Z',
     '1.0.13': '2017-07-26T23:35:32.591Z',
     '1.0.15': '2017-07-27T17:10:53.504Z',
     '1.0.16': '2017-07-30T14:22:25.010Z',
     '1.0.17': '2017-08-02T13:01:56.306Z',
     '1.0.18': '2017-08-09T13:58:04.658Z',
     '1.0.19': '2017-08-23T20:48:53.346Z',
     '1.0.20': '2017-08-25T17:07:07.540Z',
     '1.0.21': '2017-11-08T15:15:02.114Z'

regeneratorRuntime is not defined

Hi, I used technicalindicators for a while, and it's quite good somehow.
However, I just upgrade to 1.0.4 today and found the issue which is not obvious to me.
Can you please check, thanks!

==============Install=============
$ npm install technicalindicators
[email protected] E:\data\test
-- [email protected] -- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

==============Run=============
$ node
var macd = require('technicalindicators').macd
ReferenceError: regeneratorRuntime is not defined
at E:\data\test\node_modules\technicalindicators\dist\browser.js:1:16646
at e.window (E:\data\test\node_modules\technicalindicators\dist\browser.js:1:17293)
at Object. (E:\data\test\node_modules\technicalindicators\dist\browser.js:2:14270)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

ADL division by zero

In ADL.ts there is a possible division by zero if tick.high and tick.low are the same. That results in every result value afterwards being NaN.

let moneyFlowMultiplier = ((tick.close - tick.low) - (tick.high - tick.close)) /(tick.high - tick.low);

Number accuracy

Using simple numbers in JS can lead to rounding errors. Have you thought about using BigNumber js?

RSI calculation returns no value

With RSI period of 14, the calculating RSI for the following values return nothing
[ 294435, 294435, 294435, 294500, 294500, 294500, 294520, 294539, 294539, 294600, 294600, 294600, 294600, 294600, 294700 ]

but when I change some value to be
[ 294435, 294435, 294435, 294500, 294500, 294400, 294520, 294539, 294539, 294600, 294600, 294600, 294600, 294600, 294700 ]
RSI returns -> 78.49

I'm not sure in which condition RSI return nothing,
should this problem be handled by input pre-validation or output post-correction.
(or if this a bug?)

Separate candles with bearish and bullish

Some candle patterns such as Marubozu and Harami grouped bearish and bullish into one pattern. I think separating them into two should provide better usage for them.

This is flipping awesome =]

Hello mate! Apologies as this is not an issue but more of a this project is awesome! I love the Typescript support. I'm a newb at stock analysis but I'd love to share my experiences with you.

Right now I'm pulling quotes from Robinhood's API Quote.md. I'm able to obtain updates from all securities tradable on Robinhood (~7,000) every 10 seconds. What I'm aiming to do is try and find anomalies and make a move on them. I don't even know where to start, there's so many options. My first thoughts would be to find anomalies in bid/ask volume and act on that.

I would love to share my experiences and hear yours. I'm in a state of information overload! lol

[Q] Period unit

Hi, first off, thanks for this lib!

I'm not really familiar with TA, so pardon if it sounds like dumb questions.
Could you tell me what the unit the period integer refers to? Even after looking at the code and examples I can't really grasp it. Also, the values are the different close values for said period right?

Thanks!

MACD strange behavior

Hello,

I calculate two MACD with the following settings. The first time I just remove the 5 oldest data. Why this affect the most recent MACD ? There is a small difference:
MACD: 7.10857, signal: 7.10857 vs MACD: 7.10239, signal: 7.10239
Thanks !

var macdInput = {
  values            : [ length: 200 ],
  fastPeriod        : 4,
  slowPeriod        : 6,
  signalPeriod      : 2,
  SimpleMAOscillator: false,
  SimpleMASignal    : false
}
var macdInput = {
  values            : [length: 205],
  fastPeriod        : 4,
  slowPeriod        : 6,
  signalPeriod      : 2,
  SimpleMAOscillator: false,
  SimpleMASignal    : false
}

generator function not supported by IOS or Opera etc

Hi,

The generator function may not be supported by some of the web and mobile browsers as per below link. Is this correct?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable

Is yes, was wondering if we could replace the generator function with something more generic which can be supported by almost all common browsers. It would far outweight the convenience of using the generator function.

Let me know your thoughts

Regards

PlusDM MinusDM

How can I add the plusDM and minusDM points added to my adx points?

Thanks,

Ramon

indentation rules

seems there is some inconsistent indentation going on - javascript files in test are at 2 space indentation, whereas typescript files in src are at 4 space indentation

src/chart_types/Renko.ts also has mixed indentation

I'd suggest the following .editorconfig file to resolve this:

# editorconfig.org
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
indent_style = space
indent_size = 4

[*.mk]
indent_style = tab

[*.md]
indent_style = space
indent_size = 4

[{*.json,*.yml,*.bowerrc,*.babelrc}]
indent_style = space
indent_size = 2

VSCode plugin for EditorConfig: https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig

"reversedInput" parameter modified input value

Example code:

const technicalindicators = require('technicalindicators');

const values = [0.001, 0.003, 0.001, 0.003, 0.004, 0.002, 0.003, 0.003, 0.002];
console.log("before: " + values);
const smaValues = technicalindicators.SMA.calculate({ reversedInput: true, period: 4, values: values });
console.log("after: " + values);

Expected output:

before: 0.001,0.003,0.001,0.003,0.004,0.002,0.003,0.003,0.002
after: 0.001,0.003,0.001,0.003,0.004,0.002,0.003,0.003,0.002

Actual output:

before: 0.001,0.003,0.001,0.003,0.004,0.002,0.003,0.003,0.002
after: 0.002,0.003,0.003,0.002,0.004,0.003,0.001,0.003,0.001

For calculate function for indicators with reversedInput: true, input value array is reversed. As JS array use pass by reference approach, slice(0) should be used, or reverse() the array again to keep the original value of input parameter.

Need to help in setup

Hi, I want to setup the project. I have downloaded the project. Extracted the zip to the folder 'technicalindicators-master'. I ran the 'npm install --save technicalindicators'. It installed the node_modules folder in the root directory. After this I have written the below simple script to check the Bearish Engulfing Pattern.

var BearishEngulfingPattern = require('technicalindicators').BearishEngulfingPattern;
var twoDayBearishInput = {
  open: [21.44,27.89],
  high: [25.10,30.87],
  close: [23.25,15.36],
  low: [20.82,14.93],
}
var result      = BearishEngulfingPattern.hasPattern(twoDayBearishInput);
console.log( 'Is BearishEngulfingPattern? :' +result); 

But I am getting below error.

TypeError: Cannot read property 'hasPattern' of undefined
    at Object.<anonymous> (/home/lk/Downloads/technicalindicators-master/node_c975eebf38a1f.tmp:8:42)
    at Module._compile (module.js:570:32)

I am very new to the nodejs world. Could you please someone help me how to resolve this? I debug and found that the require('technicalindicators').BearishEngulfingPattern is returning unidentified.

Dojis seem too loosely defined

Hello, this is an amazing repo, just something I've noticed.

The following candlestick is coming back as a doji.
screen shot 2017-08-22 at 12 49 17 am

I think this is simply because of the approximateEqual function. I haven't yet worked on a more accurate version, but in this case...

approximateEqual(1.36171, 1.36079) = true

Bullish and Bearish

For Bullish and Bearish, they check against different indicators, some accept two candles, some accept three candles, if the user provided three candles to utilize all the indicators, for indicators that utilize two candles only they should use the last two candles not the first two

error with export

i am getting this error
(function (exports, require, module, __filename, __dirname) { export { sma, SMA } from './moving_averages/SMA';
^^^^^^
SyntaxError: Unexpected token export
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:511:25)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object. (/Users/albert/Downloads/poloniex-trade-bot-master/indicators/emasma.js:4:16)
at Module._compile (module.js:541:32)

i tested on several versions of node and OS systems!

Use it with react

Hello
I can't use this module with react, the SMA value is undefined when i launch the exemple

Can you help me ? Have you solution to use it with react js ?

Thanks

Standardize return types

Some indicators return Number arrays and others return object arrays. This lib would be even easier to use if all indicators returned data of the same type.

Would you support a PR which does this?

For example SMA returns a Number array like

[ 123, 123, 123, 123]

I am proposing it return an object array like

[{ SMA: 123 }, { SMA: 123 }, { SMA: 123 }]

Stochastic RSI

Anyone have any success doing this with RSI and Stochastic calculations of this library?

[FYI] Node.js and indicators

Hi,

thank you for this module! It saves quite a lot of time and coding. While implementing it inside an Node.js app I've noticed that this const SMA = require('technicalindicators').SMA isn't working. Upon calling SMA it throws "undefined". I looked a bit into the code and it works if I do this:
const SMA = require('technicalindicators').window.SMA

Not sure if you want/need to update your docs, but I've figured somebody might find this useful when searching issues.

Feel free to close this issue right away or let me know if I am doing something wrong.

[Webpack v2] Module not found: Error: Recursion in resolving

Hello mate,

Today I've been migrating my playground/sandbox over to webpack 2.0 and I can't get technicalindicators to resolve properly =[

It yells at me:

ERROR in ./~/technicalindicators/lib/moving_averages/SMA.js
Module not found: Error: Recursion in resolving

Here's a gist
https://gist.github.com/roblav96/e36937c29384db5530164e7373b2a1e5
of the full log and the webpack.config.js. (I hate when people leave absurdly long console.logs in the OP)

Any idea what could be the issue? I'm gonna keep looking into this and I'll let you know if I can resolve it.

Cheers!

Typescript errors

I'm coming across the following:

node_modules/technicalindicators/declarations/chart_types/HeikinAshi.d.ts(14,22): error TS2415: Class 'HeikinAshi' incorrectly extends base class 'Indicator'.
Types of property 'result' are incompatible.
Type 'CandleList' is not assignable to type 'any[]'.
Property 'length' is missing in type 'CandleList'.

Some indicators change based on # of values even above `period`

For example:, calling RSI with period 14. These are the outputs based on the inputs:

[ 0.08581, 0.08486146, 0.085, 0.08350007, 0.0839, 0.085, 0.08486001, 0.084873, 0.08573899, 0.0866, 0.08919999, 0.08690268, 0.08749999, 0.08689999, 0.0889, 0.08650001, 0.08523572, 0.0852799631
--> [ 0, 60.99, 51.52, 47.35, 47.51 ]
[ 0.08454304, 0.08581, 0.08486146, 0.085, 0.08350007, 0.0839, 0.085, 0.08486001, 0.084873, 0.08573899, 0.0866, 0.08919999, 0.08690268, 0.08749999, 0.08689999, 0.0889, 0.08650001, 0.08523572, 0.0852799631
--> [ 0, 58.84, 64.57, 54.73, 50.37, 50.52 ]

As you can see, the 2nd call has one more value at the beginning. As I understand it, in both cases the input has enough values to satisfy the period (14). Is RSI special in that it's relative or sth and it changes based on more values than period? If so, How can you ensure it matches consistently with things like TradingView, how many more values do I need to provide?

Same thing happens with PSAR.

Renko Chart

I'm quite a fan of Renko Charts and been looking for a library that does them. I've found that react-stockcharts does renko as well as many others.

What is the feasibility of adding support for Renko and other chart types to this library?

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.