I have a problem with this looping, because it is a situation that I can not solve with np.where
, why have to run DataFrame
to find the value of the gain or loss from another condition, whichever comes first .
It's working but I'm 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