Skip to content

Commit 6ee3c82

Browse files
committed
sell_stoploss: switch to ATR based stoploss.
1 parent 3c3d5e7 commit 6ee3c82

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

NostalgiaForInfinityNext.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,9 +3377,19 @@ def sell_under_min(self, current_profit: float, last_candle) -> tuple:
33773377
return False, None
33783378

33793379
def sell_stoploss(self, current_profit: float, max_profit: float, max_loss: float, last_candle, previous_candle_1, trade: 'Trade', current_time: 'datetime') -> tuple:
3380-
if (current_profit < -0.0) and (last_candle['close'] < last_candle['ema_200']) and (last_candle['cmf'] < 0.0) and (((last_candle['ema_200'] - last_candle['close']) / last_candle['close']) < 0.004) and last_candle['rsi_14'] > previous_candle_1['rsi_14'] and (last_candle['rsi_14'] > (last_candle['rsi_14_1h'] + 10.0)) and (last_candle['sma_200_dec_24']) and (current_time - timedelta(minutes=1440) > trade.open_date_utc):
3381-
return True, 'signal_stoploss_u_e_1'
3382-
3380+
if (last_candle['close'] < last_candle['ema_200']) and (last_candle['sma_200_dec_24']) and (last_candle['ema_25'] < last_candle['ema_50']) and (current_time - timedelta(minutes=1440) > trade.open_date_utc):
3381+
if (-0.12 <= current_profit < -0.08):
3382+
if (last_candle['close'] < last_candle['atr_high_thresh_1']) and (previous_candle_1['close'] > previous_candle_1['atr_high_thresh_1']):
3383+
return True, 'signal_stoploss_atr_1'
3384+
elif (-0.16 <= current_profit < -0.12):
3385+
if (last_candle['close'] < last_candle['atr_high_thresh_2']) and (previous_candle_1['close'] > previous_candle_1['atr_high_thresh_2']):
3386+
return True, 'signal_stoploss_atr_2'
3387+
elif (-0.2 <= current_profit < -0.16):
3388+
if (last_candle['close'] < last_candle['atr_high_thresh_3']) and (previous_candle_1['close'] > previous_candle_1['atr_high_thresh_3']):
3389+
return True, 'signal_stoploss_atr_3'
3390+
elif (current_profit < -0.2):
3391+
if (last_candle['close'] < last_candle['atr_high_thresh_4']) and (previous_candle_1['close'] > previous_candle_1['atr_high_thresh_4']):
3392+
return True, 'signal_stoploss_atr_4'
33833393
return False, None
33843394

33853395
def sell_pump_dec(self, current_profit: float, last_candle) -> tuple:
@@ -4457,6 +4467,13 @@ def normal_tf_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFram
44574467
dataframe['momdiv_coh'] = mom['momdiv_coh']
44584468
dataframe['momdiv_col'] = mom['momdiv_col']
44594469

4470+
# ATR
4471+
dataframe['atr'] = ta.ATR(dataframe, timeperiod=14)
4472+
dataframe['atr_high_thresh_1'] = (dataframe['high'] - (dataframe['atr'] * 3.4))
4473+
dataframe['atr_high_thresh_2'] = (dataframe['high'] - (dataframe['atr'] * 3.2))
4474+
dataframe['atr_high_thresh_3'] = (dataframe['high'] - (dataframe['atr'] * 3.0))
4475+
dataframe['atr_high_thresh_4'] = (dataframe['high'] - (dataframe['atr'] * 2.0))
4476+
44604477
# Dip protection
44614478
dataframe['tpct_change_0'] = self.top_percent_change(dataframe,0)
44624479
dataframe['tpct_change_2'] = self.top_percent_change(dataframe,2)

0 commit comments

Comments
 (0)