anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.15k stars 557 forks source link

CCI.calculate not working as expected #132

Closed emmtte closed 5 years ago

emmtte commented 6 years ago
const CCI            = require('technicalindicators').CCI;

I gave an array of 500 open,high,low and close

this my function

var outputCCI = [];
var inputCCI = { open: open, high: high, low: low, close: close, period : 20};
outputCCI = CCI.calculate(inputCCI);
for(i = 0; i < outputCCI.length; i++){ console.log(i+" "+outputCCI[i]);}

this is the result

....
460 -215.434083601272
461 -191.81539570939458
462 -155.55817239755206
463 -100.28311727014282
464 -74.03762029745936
465 -61.88281764318046
466 -60.659276332635294
467 -65.1248164464029
468 -56.41780899513718
469 -52.21607758275954
470 -41.71038824764678
471 -21.483174790459234
472 -18.59442761244018
473 -26.99755593157016
474 NaN
475 NaN
476 NaN
477 NaN
478 NaN
479 NaN
480 NaN

The first time I call my function only 480 have NaN then after call a second time I have 479 and 480 NaN and then 478,479,480 NaN......

What's wrong I use MACD, Stoch and RSI without any problems

anandanand84 commented 6 years ago

@ManuCart I'll take a look, can you attach a file with your input data

slidenerd commented 5 years ago

CCI is incorrect, I double this after checking answers using this library in Python https://github.com/mrjbq7/ta-lib

anandanand84 commented 5 years ago

This is fixed.

keremcankabadayi commented 3 years ago

I think its not fixed.