From 0806774f3834fe98609263b6fa308dea31f1dd54 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sun, 31 Aug 2025 19:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=85=A5=E5=9C=BA=E4=BF=A1?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freqtrade/templates/freqaiprimer.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index b44e139..e4aa429 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -392,11 +392,11 @@ class FreqaiPrimer(IStrategy): # 条件1: 价格接近布林带下轨 close_to_bb_lower_1h = (dataframe['close'] <= dataframe['bb_lower_1h'] * 1.02) - # 条件2: RSI 不高于阈值 - rsi_condition_1h = dataframe['rsi_1h'] < self.rsi_oversold + # 条件2: RSI 不高于阈值(放宽阈值) + rsi_condition_1h = dataframe['rsi_1h'] < 50 # 放宽 RSI 阈值 - # 条件3: StochRSI 处于超卖区域 - stochrsi_condition_1h = (dataframe['stochrsi_k_1h'] < 20) & (dataframe['stochrsi_d_1h'] < 20) + # 条件3: StochRSI 处于超卖区域(放宽阈值) + stochrsi_condition_1h = (dataframe['stochrsi_k_1h'] < 30) & (dataframe['stochrsi_d_1h'] < 30) # 放宽 StochRSI 阈值 # 条件4: MACD 上升趋势 macd_condition_1h = dataframe['macd_1h'] > dataframe['macd_signal_1h'] @@ -404,8 +404,13 @@ class FreqaiPrimer(IStrategy): # 辅助条件: 3m 和 15m 趋势确认 trend_confirmation = (dataframe['trend_3m'] == 1) & (dataframe['trend_15m'] == 1) - # 合并所有条件 - final_condition = close_to_bb_lower_1h & rsi_condition_1h & stochrsi_condition_1h & macd_condition_1h & trend_confirmation + # 合并所有条件(放宽逻辑组合) + final_condition = ( + close_to_bb_lower_1h & + (rsi_condition_1h | stochrsi_condition_1h) & # 允许 RSI 或 StochRSI 满足其一 + macd_condition_1h & + trend_confirmation + ) # 设置入场信号 dataframe.loc[final_condition, 'enter_long'] = 1 @@ -417,6 +422,7 @@ class FreqaiPrimer(IStrategy): logger.info(f" - StochRSI 超卖: {stochrsi_condition_1h.sum()} 次") logger.info(f" - MACD 上升趋势: {macd_condition_1h.sum()} 次") logger.info(f" - 趋势确认: {trend_confirmation.sum()} 次") + logger.info(f" - 最终条件: {final_condition.sum()} 次") # 日志记录 if dataframe['enter_long'].sum() > 0: