Closed xmspix closed 4 years ago
sorry it was my mistake i didn't reverse the close prices
It still gives the same output, how did you resolve?
hi, you should try to reverse the data...
in my case i take stocks data from yahoo, here is what i did and it worked :
export const SMA = ({ values, period }) => { return Indicator.SMA.calculate({ period: period, values: values.reverse() }).reverse()[0]; };
export const EMA = ({ values, period }) => { return Indicator.EMA.calculate({ period: period, values: values.reverse() }).reverse()[0]; };
On Thu, Mar 26, 2020 at 8:28 PM tusharsinghal1610 notifications@github.com wrote:
It still gives the same output, how did you resolve?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/anandanand84/technicalindicators/issues/204#issuecomment-604601030, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADJATXTZPJA7KG2UKANJEUDRJONDLANCNFSM4K2QR7YQ .
I have my data suppose [4,5,6,7,8,9] if i use period 4 EMA gives = 7.5 (just the simple average of last four) SMA gives = 5.5 (just the simple average of first four)
actually when you are using reverse() inside function , it reverses array two times , thus gives different averages one starting , and one ending
EMA and SMA with same period returns the same result