diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index 2acfe7e3..ae738150 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -741,7 +741,8 @@ class FreqaiPrimer(IStrategy): # 确保 StochRSI 指标已正确计算 # 将 1h 数据重新索引到主时间框架 (3m),并填充缺失值 - df_1h = df_1h.set_index('date').reindex(dataframe['date']).ffill().bfill().reset_index() + # 注意:只使用 ffill()(向前填充),不要用 bfill()(避免数据前瞻偏差) + df_1h = df_1h.set_index('date').reindex(dataframe['date']).ffill().reset_index() df_1h = df_1h.rename(columns={'index': 'date'}) # Include macd_1h, macd_signal_1h, ema_5_1h, ema_20_1h, ema5_cross_above_ema20 in the column selection df_1h = df_1h[['date', 'rsi_1h', 'trend_1h', 'ema_50_1h', 'ema_200_1h', 'bb_lower_1h', 'bb_upper_1h', 'stochrsi_k_1h', 'stochrsi_d_1h', 'macd_1h', 'macd_signal_1h', 'macd_hist_1h', 'ema_5_1h', 'ema_20_1h', 'ema20_slope_normalized', 'ema5_cross_above_ema20']].ffill()