anandanand84 / technicalindicators

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

Calculated EMA seems not accurately #220

Open redstrike opened 4 years ago

redstrike commented 4 years ago

I am trying to calculate EMA and SMA of the same data values. However, the result is the same. When comparing to TradingView's calculated EMA, it's not matched.

image

juanvisoler commented 4 years ago

Same for MACD

juanvisoler commented 4 years ago

Probably because it's using EMA by default

juanvisoler commented 4 years ago

@redstrike EMA looks correct. Depending on the parameters they can yield the same results or not.

Look at this example:

const SMA = require('technicalindicators').SMA let period = 3; let values = [1.5554, 1.5555, 1.5558,1.5560]; SMA.calculate({period : period, values : values})

const EMA = require('technicalindicators').EMA let period = 3; let values = [1.5554, 1.5555, 1.5558,1.5560]; EMA.calculate({period : period, values : values})

redstrike commented 4 years ago

@juanvisoler I did an EMA calculation with a larger dataset before trying the above simple example and compare it with other true sources such as TradingView, and believe that EMA result is not accurate.

juanvisoler commented 4 years ago

@redstrike can you give an example?

redstrike commented 4 years ago

image finmath's EMA result is more accurate as expected. Also, I compare the result with TradingView's calculated result, so I want to report this issue. If you believe that technicalindicators' EMA result is correct, then I have no more comment.

southwhale commented 3 years ago

我用EMA计算的结果也是有问题哎

southwhale commented 3 years ago

我用EMA计算的结果也是有问题哎

是我错了,当数据量较小时计算结果似乎不正确,但当数据量足够大时是没问题的,这个库非常棒

southwhale commented 3 years ago

我用EMA计算的结果也是有问题哎

是我错了,当数据量较小时计算结果似乎不正确,但当数据量足够大时是没问题的,这个库非常棒

唯一的遗憾是只能nextValue不能updateCurrentValue

saru2020 commented 1 year ago

@anandanand84 can you please look into this issue please? looks like this is what's causing the issue in MACD(EMA based) as mentioned here: https://github.com/anandanand84/technicalindicators/issues/249#issuecomment-1321147767

egranville commented 1 year ago

Also comparing it to TradingView's EMA and seems incorrect