Closed c0nf1ck closed 4 years ago
Do you mean to say using getResult and nextValues have different results.
Take a look at the the test case here https://github.com/anandanand84/technicalindicators/blob/master/test/volatility/BollingerBands.js
Hey @anandanand84 thanks for the fast reply.
Yeah i know, i'm using getResult only when there's no value inside the array of that particular symbol. But after some time, the values are wrong as u can see.. I don't know why
how do you compare the values between tradingview and this, because all you are getting is the last value of the get result in here. It may have multiple values based on the size of C and period. So you may be comparing the wrong values.
For example you are comparing fifth value of your result with first value of tradingview, because you are ignoring the first four values of the result.
how do you compare the values between tradingview and this, because all you are getting is the last value of the get result in here.
I'm using only the last value and comparing based on time, for example at 2019-11-21T05:25:10-03:00 i get this from the lib: Upper: 0.0068462318 Lower: 0.0067572348
on tradingview the value for the same moment is: Upper: 0.006700 Lower: 0.006660
But i think i found the error, im not saving the 'nextValue' back in the array. Changed my method to this:
let bbResult = [], bbResults = []
const BollingerBands = function (C, period, stdDev, symbol, next) {
if (!bbResult[symbol]) {
bbResult[symbol] = new bb({ values: C, period: period, stdDev: stdDev })
bbResults = bbResult[symbol].getResult()
} else bbResults.push(bbResult[symbol].nextValue(next))
return bbResults[bbResults.length - 1]
}
I'll see if its correct after some time.
Thanks :)
Probably my error, as described above.
Thanks @anandanand84
After using this lib for hours, i'm seeing some divergence in the values calculated using nextValue.
Maybe i'm doing something wrong? For example