1 回答

TA貢獻1851條經(jīng)驗 獲得超3個贊
你可以使用一個變量,這里adding,既可以注意到你已經(jīng)遇到了條件 1,記住你當時得到的值,也可以看到你還沒有遇到條件 2,所以可以繼續(xù)添加它:
adding = None
for i in range(1,len(close)):
if first_condition():
adding = close.close[i]
list.append(adding) # i want to append close.close[i] for al the next cells i (i+1, i+2,...)
#until the SECOND condition become TRUE.
# SECOND CONDITION:
elif if (close.fast_ema[i-1] > close.int_ema[i-1] and close.fast_ema[i] > close.slow_ema[i]:
list.append(close.close)
adding = None
else:
if adding is not None:
list.append(adding)
else:
list.append(0)
添加回答
舉報