当前行情价格必须低于ema50

This commit is contained in:
zhangkun9038@dingtalk.com 2025-08-23 00:07:01 +08:00
parent 05f2dd4a99
commit c5b5c8e235

View File

@ -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"
# 仅在日志中使用最后一行的值