优化亏损交易策略
This commit is contained in:
parent
cc6750fa47
commit
040473d4d3
|
|
@ -425,14 +425,24 @@ class MarketScanner:
|
||||||
if ema20 and ema50:
|
if ema20 and ema50:
|
||||||
if current_price > ema20 > ema50: # 上升趋势
|
if current_price > ema20 > ema50: # 上升趋势
|
||||||
if trend_4h in ('up', 'neutral', None):
|
if trend_4h in ('up', 'neutral', None):
|
||||||
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
|
# 冲突检查
|
||||||
if direction is None:
|
if direction == 'SELL':
|
||||||
direction = 'BUY'
|
signal_strength = 0
|
||||||
|
direction = None
|
||||||
|
else:
|
||||||
|
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
|
||||||
|
if direction is None:
|
||||||
|
direction = 'BUY'
|
||||||
elif current_price < ema20 < ema50: # 下降趋势
|
elif current_price < ema20 < ema50: # 下降趋势
|
||||||
if trend_4h in ('down', 'neutral', None):
|
if trend_4h in ('down', 'neutral', None):
|
||||||
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
|
# 冲突检查
|
||||||
if direction is None:
|
if direction == 'BUY':
|
||||||
direction = 'SELL'
|
signal_strength = 0
|
||||||
|
direction = None
|
||||||
|
else:
|
||||||
|
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
|
||||||
|
if direction is None:
|
||||||
|
direction = 'SELL'
|
||||||
|
|
||||||
# 价格与EMA20关系
|
# 价格与EMA20关系
|
||||||
if ema20:
|
if ema20:
|
||||||
|
|
|
||||||
|
|
@ -440,10 +440,16 @@ class TradingStrategy:
|
||||||
if trend_4h in ('up', 'neutral'):
|
if trend_4h in ('up', 'neutral'):
|
||||||
# OPTIMIZATION: 添加 RSI 过滤
|
# OPTIMIZATION: 添加 RSI 过滤
|
||||||
if rsi is None or rsi < 70:
|
if rsi is None or rsi < 70:
|
||||||
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
|
# 冲突检查:如果已有方向且与当前不符,则是严重冲突
|
||||||
reasons.append("EMA20上穿EMA50,上升趋势")
|
if direction == 'SELL':
|
||||||
if direction is None:
|
reasons.append("❌ 信号冲突:MACD看空但EMA看多")
|
||||||
direction = 'BUY'
|
signal_strength = 0
|
||||||
|
direction = None
|
||||||
|
else:
|
||||||
|
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
|
||||||
|
reasons.append("EMA20上穿EMA50,上升趋势")
|
||||||
|
if direction is None:
|
||||||
|
direction = 'BUY'
|
||||||
else:
|
else:
|
||||||
reasons.append(f"1H均线向上但4H趋势相反({trend_4h}),禁止逆势")
|
reasons.append(f"1H均线向上但4H趋势相反({trend_4h}),禁止逆势")
|
||||||
elif current_price < ema20 < ema50: # 下降趋势
|
elif current_price < ema20 < ema50: # 下降趋势
|
||||||
|
|
@ -451,10 +457,16 @@ class TradingStrategy:
|
||||||
if trend_4h in ('down', 'neutral'):
|
if trend_4h in ('down', 'neutral'):
|
||||||
# OPTIMIZATION: 添加 RSI 过滤
|
# OPTIMIZATION: 添加 RSI 过滤
|
||||||
if rsi is None or rsi > 30:
|
if rsi is None or rsi > 30:
|
||||||
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
|
# 冲突检查:如果已有方向且与当前不符,则是严重冲突
|
||||||
reasons.append("EMA20下穿EMA50,下降趋势")
|
if direction == 'BUY':
|
||||||
if direction is None:
|
reasons.append("❌ 信号冲突:MACD看多但EMA看空")
|
||||||
direction = 'SELL'
|
signal_strength = 0
|
||||||
|
direction = None
|
||||||
|
else:
|
||||||
|
signal_strength += TREND_SIGNAL_WEIGHTS['ema_cross']
|
||||||
|
reasons.append("EMA20下穿EMA50,下降趋势")
|
||||||
|
if direction is None:
|
||||||
|
direction = 'SELL'
|
||||||
else:
|
else:
|
||||||
reasons.append(f"1H均线向下但4H趋势相反({trend_4h}),禁止逆势")
|
reasons.append(f"1H均线向下但4H趋势相反({trend_4h}),禁止逆势")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user