0
Guys I’m having trouble with this looping, because it’s a situation that I can’t solve with np.where
, why does the DataFrame
to find the value of the gain or loss from another condition, which comes first.
It’s working but I keep getting this Warning:
C:\Users\Jair\Anaconda3\lib\site-packages\ipykernel_launcher.py:14: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
def estrategia_2_alta(candles):
for i in range(1,len(candles)):
if candles['Twintower'][i]== 1:
loop2 = i
for twin in range(loop2+1, len(candles)):
if candles['askclose'][twin]>=candles['Gain'][i]:
candles['Resultado'][i] = candles['Tamanho_Twin'][i]*GainC
break
elif candles['askhigh'][twin]>=candles['Gain'][i]:
candles['Resultado'][i] = candles['Tamanho_Twin'][i]*GainC
break
elif candles['askclose'][twin]<=candles['Loss'][i]:
candles['Resultado'][i] = candles['Tamanho_Twin'][i]*(-StopC)
break
elif candles['asklow'][twin]<=candles['Loss'][i]:
candles['Resultado'][i] = candles['Tamanho_Twin'][i]*(-StopC)
break