sdcoffey / techan

Technical Analysis Library for Golang

Home Page:https://godoc.org/github.com/sdcoffey/techan

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

should EMA consider time window?

SunRunAwayAwayAway opened this issue · comments

Hi, I see the implementation of EMA does not consider the time window, is it correct?

func (ema *emaIndicator) Calculate(index int) big.Decimal {
if cachedValue := returnIfCached(ema, index, func(i int) big.Decimal {
return NewSimpleMovingAverage(ema.indicator, ema.window).Calculate(i)
}); cachedValue != nil {
return *cachedValue
}
todayVal := ema.indicator.Calculate(index).Mul(ema.alpha)
result := todayVal.Add(ema.Calculate(index - 1).Mul(ema.alpha))
cacheResult(ema, index, result)
return result
}

Also, is RSI correct since RSI relays on EMA?

commented

I think it's incorrect, window is not used anywhere in the calculation.

Fixed as of 0.12.1! Shoutout to @danhenke and @joelnordell for the fix