调整入场逻辑
This commit is contained in:
parent
54effd23c1
commit
3210610282
@ -392,11 +392,11 @@ class FreqaiPrimer(IStrategy):
|
||||
# 条件1: 价格接近布林带下轨
|
||||
close_to_bb_lower_1h = (dataframe['close'] <= dataframe['bb_lower_1h'] * 1.02)
|
||||
|
||||
# 条件2: RSI 不高于阈值(放宽阈值)
|
||||
rsi_condition_1h = dataframe['rsi_1h'] < 50 # 放宽 RSI 阈值
|
||||
# 条件2: RSI 不高于阈值(更严格)
|
||||
rsi_condition_1h = dataframe['rsi_1h'] < 45 # 更严格的 RSI 阈值
|
||||
|
||||
# 条件3: StochRSI 处于超卖区域(放宽阈值)
|
||||
stochrsi_condition_1h = (dataframe['stochrsi_k_1h'] < 30) & (dataframe['stochrsi_d_1h'] < 30) # 放宽 StochRSI 阈值
|
||||
# 条件3: StochRSI 处于超卖区域(更严格)
|
||||
stochrsi_condition_1h = (dataframe['stochrsi_k_1h'] < 25) & (dataframe['stochrsi_d_1h'] < 25) # 更严格的 StochRSI 阈值
|
||||
|
||||
# 条件4: MACD 上升趋势
|
||||
macd_condition_1h = dataframe['macd_1h'] > dataframe['macd_signal_1h']
|
||||
@ -414,7 +414,8 @@ class FreqaiPrimer(IStrategy):
|
||||
# 合并所有条件(增加成交量和布林带宽度过滤)
|
||||
final_condition = (
|
||||
close_to_bb_lower_1h &
|
||||
(rsi_condition_1h | stochrsi_condition_1h) & # 允许 RSI 或 StochRSI 满足其一
|
||||
rsi_condition_1h & # 严格要求RSI满足条件
|
||||
stochrsi_condition_1h & # 严格要求StochRSI满足条件
|
||||
macd_condition_1h &
|
||||
volume_spike & # 成交量显著放大
|
||||
bb_width_condition & # 布林带宽度过滤
|
||||
@ -606,11 +607,11 @@ class FreqaiPrimer(IStrategy):
|
||||
|
||||
# 动态调整止损范围
|
||||
if current_profit > 0.05: # 利润超过5%时
|
||||
return -2.5 * atr / current_rate # 大幅扩大止损范围,让利润奔跑
|
||||
return -3.0 * atr / current_rate # 更大幅扩大止损范围,让利润奔跑
|
||||
elif current_profit > 0.03: # 利润超过3%时
|
||||
return -2.0 * atr / current_rate # 中等扩大止损范围
|
||||
return -2.5 * atr / current_rate # 更中等扩大止损范围
|
||||
elif current_profit > 0.01: # 利润超过1%时
|
||||
return -1.5 * atr / current_rate # 轻微扩大止损范围
|
||||
return -2.0 * atr / current_rate # 更轻微扩大止损范围
|
||||
|
||||
# 在强劲牛市中,即使小亏损也可以容忍更大回调
|
||||
if current_state == 'strong_bull' and current_profit > -0.01:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user