Skip to content

Commit 425abf8

Browse files
committed
Buy condition 48: Uptrend mode.
1 parent 217312e commit 425abf8

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

NostalgiaForInfinityNext.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class NostalgiaForInfinityNext(IStrategy):
214214
"buy_condition_45_enable": True,
215215
"buy_condition_46_enable": True,
216216
"buy_condition_47_enable": True,
217+
"buy_condition_48_enable": True,
217218
#############
218219
}
219220

@@ -1180,6 +1181,26 @@ class NostalgiaForInfinityNext(IStrategy):
11801181
"safe_pump_type" : "120",
11811182
"safe_pump_period" : "24",
11821183
"btc_1h_not_downtrend" : False
1184+
},
1185+
48: {
1186+
"ema_fast" : True,
1187+
"ema_fast_len" : "12",
1188+
"ema_slow" : True,
1189+
"ema_slow_len" : "12",
1190+
"close_above_ema_fast" : True,
1191+
"close_above_ema_fast_len" : "200",
1192+
"close_above_ema_slow" : True,
1193+
"close_above_ema_slow_len" : "200",
1194+
"sma200_rising" : True,
1195+
"sma200_rising_val" : "30",
1196+
"sma200_1h_rising" : True,
1197+
"sma200_1h_rising_val" : "24",
1198+
"safe_dips" : False,
1199+
"safe_dips_type" : "130",
1200+
"safe_pump" : False,
1201+
"safe_pump_type" : "120",
1202+
"safe_pump_period" : "24",
1203+
"btc_1h_not_downtrend" : False
11831204
}
11841205
}
11851206

@@ -1694,6 +1715,14 @@ class NostalgiaForInfinityNext(IStrategy):
16941715
buy_47_cti_1h_max = 0.95
16951716
buy_47_crsi_1h_min = 10.0
16961717

1718+
buy_48_ewo_min = 8.0
1719+
buy_48_ewo_1h_min = 14.0
1720+
buy_48_r_min = -25.0
1721+
buy_48_r_1h_min = -50.0
1722+
buy_48_r_1h_max = -10.0
1723+
buy_48_cti_1h_min = 0.5
1724+
buy_48_crsi_1h_min = 10.0
1725+
16971726
# Sell
16981727

16991728
sell_condition_1_enable = True
@@ -3171,6 +3200,12 @@ def sell_quick_mode(self, current_profit: float, max_profit:float, last_candle,
31713200

31723201
return False, None
31733202

3203+
def sell_uptrend_mode(self, current_profit: float, max_profit:float, last_candle, previous_candle_1) -> tuple:
3204+
if (current_profit < -0.05) and (last_candle['sma_200_dec_24']) and (last_candle['ema_25'] < last_candle['ema_50']):
3205+
return True, 'sell_up_stoploss_1'
3206+
3207+
return False, None
3208+
31743209
def sell_ichi(self, current_profit: float, max_profit:float, max_loss:float, last_candle, previous_candle_1, trade: 'Trade', current_time: 'datetime') -> tuple:
31753210
if (0.0 < current_profit < 0.05) and (current_time - timedelta(minutes=1440) > trade.open_date_utc) and (last_candle['rsi_14'] > 78.0):
31763211
return True, 'signal_profit_ichi_u'
@@ -3304,6 +3339,12 @@ def custom_sell(self, pair: str, trade: 'Trade', current_time: 'datetime', curre
33043339
if sell and (signal_name is not None):
33053340
return f"{signal_name} ( {buy_tag} )"
33063341

3342+
# Uptrend sell mode
3343+
if all(c in ['48'] for c in buy_tags):
3344+
sell, signal_name = self.sell_uptrend_mode(current_profit, max_profit, last_candle, previous_candle_1)
3345+
if sell and (signal_name is not None):
3346+
return f"{signal_name} ( {buy_tag} )"
3347+
33073348
# Ichi Trade management
33083349
if all(c in ['39'] for c in buy_tags):
33093350
sell, signal_name = self.sell_ichi(current_profit, max_profit, max_loss, last_candle, previous_candle_1, trade, current_time)
@@ -4656,6 +4697,29 @@ def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
46564697
item_buy_logic.append(dataframe['cti_1h'] > self.buy_47_cti_1h_min)
46574698
item_buy_logic.append(dataframe['cti_1h'] < self.buy_47_cti_1h_max)
46584699

4700+
# Condition #48 - Uptrend mode
4701+
elif index == 48:
4702+
# Non-Standard protections
4703+
item_buy_logic.append(dataframe['ema_200_1h'] > dataframe['ema_200_1h'].shift(12))
4704+
item_buy_logic.append(dataframe['ema_200_1h'].shift(12) > dataframe['ema_200_1h'].shift(24))
4705+
item_buy_logic.append(dataframe['moderi_32'])
4706+
item_buy_logic.append(dataframe['moderi_64'])
4707+
item_buy_logic.append(dataframe['moderi_96'])
4708+
4709+
# Logic
4710+
item_buy_logic.append(dataframe['ewo'] > self.buy_48_ewo_min)
4711+
item_buy_logic.append(dataframe['ewo_1h'] > self.buy_48_ewo_1h_min)
4712+
item_buy_logic.append(dataframe['r_480'] > self.buy_48_r_min)
4713+
item_buy_logic.append(dataframe['r_480_1h'] > self.buy_48_r_1h_min)
4714+
item_buy_logic.append(dataframe['r_480_1h'] < self.buy_48_r_1h_max)
4715+
item_buy_logic.append(dataframe['r_480_1h'] > dataframe['r_480_1h'].shift(12))
4716+
item_buy_logic.append(dataframe['cti_1h'] > self.buy_48_cti_1h_min)
4717+
item_buy_logic.append(dataframe['crsi_1h'] > self.buy_48_crsi_1h_min)
4718+
item_buy_logic.append(dataframe['cti'].shift(1).rolling(12).min() < -0.5)
4719+
item_buy_logic.append(dataframe['cti'].shift(1).rolling(12).max() < 0.0)
4720+
item_buy_logic.append(dataframe['cti'].shift(1) < 0.0)
4721+
item_buy_logic.append(dataframe['cti'] > 0.0)
4722+
46594723
item_buy_logic.append(dataframe['volume'] > 0)
46604724
item_buy = reduce(lambda x, y: x & y, item_buy_logic)
46614725
dataframe.loc[item_buy, 'buy_tag'] += f"{index} "

0 commit comments

Comments
 (0)