I'm trying to create support and resistance for the stocks chart. However, I got this error. Here is my code:
def isResistance(df,i):
resistance = df['High'][i] > df['High'][i-1] and df['High'][i] > df['High'][i+1] \
and df['High'][i] > df['High'][i+2] and df['High'][i] > df['High'][i-2] \
and df['High'][i] > df['High'][i+3] and df['High'][i] > df['High'][i-3]
return resistance
And I'm trying to take all of the list of the support and resistance by using this:
levels = []
for i in range(2,df.shape[0]-2):
if isSupport(df,i):
levels.append((i,df['Low'][i]))
elif isResistance(df,i):
levels.append((i,df['High'][i]))
Then the error occurs in this part:
and df['High'][i] > df['High'][i+3] and df['High'][i] > df['High'][i-3]
However, in this code there is no any errors:
def isSupport(df,i):
support = df['Low'][i] < df['Low'][i-1] and df['Low'][i] < df['Low'][i+1] \
and df['Low'][i] < df['Low'][i+2] and df['Low'][i] < df['Low'][i-2] \
and df['Low'][i] < df['Low'][i+3] and df['Low'][i] < df['Low'][i-3]
return support
Do you have any idea to solve this issue? Thank you