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