请教,如何计算“最近一次价格突破BOLL指标上轨到当前的周期数”? barlast函数的cond 类型?
klines = api.get_kline_serial(“DCE.p2109”, 3600, data_length=36) boll = BOLL(klines, 26, 2) topline = boll[“top”] bottomline = boll[“bottom”]
cro1 = close_seris>topline and ref(close_seris,1)<ref(topline,1) cro2 = close_seris ref(topline,1)
sj1 = barlast(cro1) sj2 = barlast(cro2)
print(sj1 , sj2)
烦请赐教!
作为小白,我可能会加个变量,判断价格突破轨道,然后判断api.is_changing(klines.iloc[-1],datatime),变量+=1 ………………
klines = api.get_kline_serial(“DCE.p2109”, 3600, data_length=36)
boll = BOLL(klines, 26, 2)
topline = boll[“top”]
bottomline = boll[“bottom”]
cro1 = close_seris>topline and ref(close_seris,1)<ref(topline,1)
cro2 = close_seris ref(topline,1)
sj1 = barlast(cro1)
sj2 = barlast(cro2)
print(sj1 , sj2)
烦请赐教!