Can you please advise where my code is wrong. Why am I getting this error mesg-
Reliance ['long_position'] = np.nan
for x in range (len (Reliance)):
if Reliance.Close[x] > Reliance.SMA20[x]:
Reliance['long_position'][x] = 1
if Reliance.Close[x] <= Reliance.SMA20[x]:
Reliance['long_position'][x] = 0
I am calculating SMA20 and Close in other section of code. Warning: A value is trying to be set on a copy of a slice from a DataFrame
See below picture for more details please.