全新的策略
This commit is contained in:
parent
acc7fc8fec
commit
2a946731d7
@ -61,48 +61,4 @@ class FreqaiPrimer(IStrategy):
|
||||
(dataframe['close'].shift(1) < dataframe['open'].shift(1)) & # 前一根是阴线
|
||||
(dataframe['close'] > dataframe['open']) & # 当前是阳线
|
||||
(dataframe['close'] > dataframe['open'].shift(1)) & # 吞没前一根
|
||||
(dataframe['open'] < dataframe['close'].shift(1))
|
||||
)
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
# 做多条件
|
||||
dataframe.loc[
|
||||
(
|
||||
# 3m 周期:价格触碰下轨且 RSI 超卖
|
||||
(dataframe['close'] <= dataframe['bb_lower_3m']) &
|
||||
(dataframe['rsi_3m'] < self.rsi_oversold) &
|
||||
# 15m 周期:RSI 超卖
|
||||
(dataframe['rsi_15m'] < self.rsi_oversold) &
|
||||
# 1h 周期:价格在下轨附近
|
||||
(dataframe['close'] <= dataframe['bb_lower_1h']) &
|
||||
# K线形态确认
|
||||
(dataframe['bullish_engulfing']) &
|
||||
# 成交量过滤:成交量高于 20 周期均量
|
||||
(dataframe['volume'] > dataframe['volume_ma'])
|
||||
),
|
||||
'enter_long'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
# 做多退出:价格触碰布林带上轨或 RSI 超买
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe['close'] >= dataframe['bb_upper_3m']) |
|
||||
(dataframe['rsi_3m'] > self.rsi_overbought)
|
||||
),
|
||||
'exit_long'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def custom_stoploss(self, pair: str, trade: 'Trade', current_time, current_rate: float,
|
||||
current_profit: float, **kwargs) -> float:
|
||||
# 动态止损基于 ATR
|
||||
dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
|
||||
last_candle = dataframe.iloc[-1]
|
||||
atr = last_candle['atr']
|
||||
if atr > 0:
|
||||
return -1.5 * atr / current_rate # 动态止损为 1.5 倍 ATR
|
||||
return self.stoploss # 回退到固定止损
|
||||
Loading…
x
Reference in New Issue
Block a user