From 328769e0e1d9354ea0488965a03da0c42c854d72 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Mon, 28 Apr 2025 12:25:20 +0800 Subject: [PATCH] up --- freqtrade/templates/FreqaiExampleStrategy.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/freqtrade/templates/FreqaiExampleStrategy.py b/freqtrade/templates/FreqaiExampleStrategy.py index 9adcc523..08f8bdba 100644 --- a/freqtrade/templates/FreqaiExampleStrategy.py +++ b/freqtrade/templates/FreqaiExampleStrategy.py @@ -222,7 +222,19 @@ class FreqaiExampleStrategy(IStrategy): "exit_long" ] = 1 return df - + def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame: + # 改进买入信号条件 + enter_long_conditions = [ + (df["rsi"] < df["buy_rsi_pred"]) & (df["rsi"].shift(1) >= df["buy_rsi_pred"]), # RSI 下穿买入阈值 + df["volume"] > df["volume"].rolling(window=10).mean(), # 成交量高于近期均值 + df["close"] > df["bb_middleband"] # 价格高于布林带中轨 + ] + if enter_long_conditions: + df.loc[ + reduce(lambda x, y: x & y, enter_long_conditions), + ["enter_long", "enter_tag"] + ] = (1, "long") + return df def confirm_trade_entry( self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, current_time, entry_tag, side: str, **kwargs