From afcf7e51dc58372e6db3fe05b0984a4ad1c40368 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sun, 31 Aug 2025 20:07:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=BC=E5=90=883m,15m,1h=E7=9A=84=E5=90=84?= =?UTF-8?q?=E4=B8=AA=E6=8C=87=E6=A0=87=E7=9A=84=E5=85=A5=E5=9C=BA=E5=87=BA?= =?UTF-8?q?=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freqtrade/templates/freqaiprimer.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index 0cd0f729..0d50c037 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -395,11 +395,11 @@ class FreqaiPrimer(IStrategy): close_to_bb_lower_1h = (dataframe['close'] <= dataframe['bb_lower_1h'] * 1.03) # 放宽到3%偏差 # 条件2: RSI 不高于阈值(根据市场状态动态调整) - rsi_threshold = 45 if current_state in ['strong_bull', 'weak_bull'] else 40 + rsi_threshold = 50 if current_state in ['strong_bull', 'weak_bull'] else 45 rsi_condition_1h = dataframe['rsi_1h'] < rsi_threshold # 条件3: StochRSI 处于超卖区域(根据市场状态动态调整) - stochrsi_threshold = 30 if current_state in ['strong_bull', 'weak_bull'] else 20 + stochrsi_threshold = 35 if current_state in ['strong_bull', 'weak_bull'] else 25 stochrsi_condition_1h = (dataframe['stochrsi_k_1h'] < stochrsi_threshold) & (dataframe['stochrsi_d_1h'] < stochrsi_threshold) # 条件4: MACD 上升趋势 @@ -416,14 +416,16 @@ class FreqaiPrimer(IStrategy): 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 & - (volume_spike | bb_width_condition) & # 成交量或布林带宽度满足其一即可 - trend_confirmation + # 至少满足5个条件中的3个 + condition_count = ( + close_to_bb_lower_1h.astype(int) + + rsi_condition_1h.astype(int) + + stochrsi_condition_1h.astype(int) + + macd_condition_1h.astype(int) + + (volume_spike | bb_width_condition).astype(int) + # 成交量或布林带宽度满足其一即可 + trend_confirmation.astype(int) ) + final_condition = condition_count >= 3 # 设置入场信号 dataframe.loc[final_condition, 'enter_long'] = 1