MyTT icon indicating copy to clipboard operation
MyTT copied to clipboard

CROSS函数计算结果处理错误,修正建议

Open ghost0917 opened this issue 2 years ago • 2 comments

def CROSS(S1, S2): # 判断向上金叉穿越 CROSS(MA(C,5),MA(C,10)) 判断向下死叉穿越 CROSS(MA(C,10),MA(C,5))
return np.concatenate(([False], np.logical_not((S1>S2)[:-1]) & (S1>S2)[1:])) # 不使用0级函数,移植方便 by jqz1226

改成: def CROSS(S1, S2): # 判断向上金叉穿越 CROSS(MA(C,5),MA(C,10)) 判断向下死叉穿越 CROSS(MA(C,10),MA(C,5)) return np.concatenate(([False], np.logical_not((S1 > S2)[:-1]) & (S1 > S2)[1:].reset_index(drop=True)))

ghost0917 avatar Aug 19 '22 01:08 ghost0917

我也遇到这个问题,修正有效

tgmnb avatar Sep 11 '23 03:09 tgmnb

计算结果确实与同花顺的有出入,改成如下代码后,结果一致了:

def CROSS(S1, S2):                  
    res = pd.Series(S1) > pd.Series(S2)
    return ((res == True) & (res.shift(-1) == False)).shift()

hotwind2015 avatar Jan 30 '24 15:01 hotwind2015