From c5b5c8e2358b04960c7331a543f47b2798b38631 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Sat, 23 Aug 2025 00:07:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E5=89=8D=E8=A1=8C=E6=83=85=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E5=BF=85=E9=A1=BB=E4=BD=8E=E4=BA=8Eema50?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freqtrade/templates/freqaiprimer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index 53356fb..6054845 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -745,6 +745,10 @@ class FreqaiPrimer(IStrategy): bearish_signal_aligned = bearish_signal.reindex(dataframe.index, method='ffill').fillna(False) stochrsi_overbought = self.is_stochrsi_overbought(dataframe, period=10, threshold=85) stochrsi_overbought_aligned = stochrsi_overbought.reindex(dataframe.index, method='ffill').fillna(True) + + # 计算EMA50 - 价格必须低于EMA50的硬性要求 + dataframe["ema50"] = ta.EMA(dataframe, timeperiod=50) + price_below_ema50 = dataframe["close"] < dataframe["ema50"] # 检测趋势状态 trend_status = self.detect_trend_status(dataframe, metadata) @@ -775,7 +779,7 @@ class FreqaiPrimer(IStrategy): entry_tag = "" if is_green_channel: - # 🟢 牛市绿色通道:持仓≤2个,25USDT入场,5条件需要满足4个 + # 🟢 牛市绿色通道:持仓≤2个,25USDT入场,5条件需要满足4个,且价格必须低于EMA50 cond1 = (dataframe["&-price_value_divergence"] < self.buy_threshold * 1.8) # 超宽松偏离度 cond2 = (dataframe["volume_z_score"] > volume_z_score_threshold * 0.4) # 超低成交量要求 cond3 = (dataframe["rsi"] < rsi_threshold * 1.4) # 超宽松RSI @@ -785,7 +789,7 @@ class FreqaiPrimer(IStrategy): core_conditions = [cond1, cond2, cond3, cond4, cond5] # 使用向量化操作计算满足条件的数量 satisfied_count_vector = cond1.astype(int) + cond2.astype(int) + cond3.astype(int) + cond4.astype(int) + cond5.astype(int) - buy_condition = satisfied_count_vector >= 4 + buy_condition = (satisfied_count_vector >= 4) & price_below_ema50 # 必须低于EMA50 entry_tag = "bull_green_channel" # 仅在日志中使用最后一行的值