大神帮看下,不知道逻辑错误在哪里了
def ema(self, n, array=False):
result = talib.EMA(self.high, self.low, self.close, n)
if array:
return result
emas = cps.copy() # 创造一个和cps一样大小的集合
for i in range(len(cps)):
if i == 0:
emas[i] = cps[i]
if i > 0:
emas[i] = ((n - 1) * emas[i - 1] + 2 * cps[i]) / (n + 1)
return emas