From d1b3ac3ae2486aaa405f1e14b341fa5342356166 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Tue, 10 Feb 2026 21:49:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=9C=A8=E5=9B=9E=E6=B5=8B?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=B8=AD=E6=B8=85=E6=A5=9A=E5=9C=B0=E7=9C=8B?= =?UTF-8?q?=E5=88=B0=20EMA20=20=E4=BB=B0=E8=A7=92=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E8=B6=85=E8=BF=87=E9=98=88=E5=80=BC=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freqtrade/templates/freqaiprimer.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index ada16ba9..6bbb7d53 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -21,7 +21,7 @@ UTC_PLUS_8 = timezone(timedelta(hours=8)) class FreqaiPrimer(IStrategy): # 策略参数 - 使用custom_roi替代minimal_roi字典 loglevel = "warning" - minimal_roi = {} + minimal_roi = {}self.add_position_callback.value # 启用自定义ROI回调函数 use_custom_roi = True @@ -500,6 +500,8 @@ class FreqaiPrimer(IStrategy): def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # ========== 新增:ML目标变量数据新鲜度监控 ========== # 检查FreqAI模型预测数据的新鲜度,确保使用最新的预测结果 + # 注意:ML预测数据通常比普通量化数据滞后一个timeframe(约3分钟) + # 这是FreqAI的正常工作机制,不影响策略有效性 try: # 获取FreqAI分析过的数据帧 analyzed_df, _ = self.dp.get_analyzed_dataframe(metadata['pair'], self.timeframe) @@ -1513,6 +1515,16 @@ class FreqaiPrimer(IStrategy): ema_trend_filter_1h_recent = ema_trend_filter_1h.iloc[-5:].tolist() ema_trend_filter_1h_visual = ''.join(['✅' if x else '❌' for x in ema_trend_filter_1h_recent]) self.strategy_log(f" - [{ema_trend_filter_1h_visual}]#1hEMA趋势过滤(宽松版)【用于业务逻辑】") + + # EMA20仰角状态可视化 + if 'ema20_slope_normalized' in df.columns: + # 获取最近5个EMA20斜率值 + ema20_slope_values = df['ema20_slope_normalized'].iloc[-5:] + # 检查是否超过阈值 + ema20_slope_threshold = self.ema20_slope_threshold.value + ema20_slope_above_threshold = ema20_slope_values > ema20_slope_threshold + ema20_slope_visual = ''.join(['✅' if x else '❌' for x in ema20_slope_above_threshold]) + self.strategy_log(f" - [{ema20_slope_visual}]#EMA20仰角>阈值(越绿越大)【用于趋势强度】") # ========== 诊断统计结束 ==========