diff --git a/monitors/macd_boll.py b/monitors/macd_boll.py index b062886..9c03e15 100644 --- a/monitors/macd_boll.py +++ b/monitors/macd_boll.py @@ -36,8 +36,8 @@ def stratergy_run(symbol, interval, df, debug): upperband, middleband, lowerband = talib.BBANDS(df['close'], timeperiod=bollinger_length, nbdevup=bollinger_mult, nbdevdn=bollinger_mult, matype=0) # 生成交易信号 - long_condition = (macd.shift(1) <= 0) & (macd > 0) & (df['high'] < upperband) & (df['close'] > fast_ema | df['close'] > slow_ema) - short_condition = (macd.shift(1) >= 0) & (macd < 0) & (df['low'] > lowerband) & (df['close'] < fast_ema | df['close'] < slow_ema) + long_condition = (macd.shift(1) <= 0) & (macd > 0) & (df['high'] < upperband) & ((df['close'] > fast_ema) | (df['close'] > slow_ema)) + short_condition = (macd.shift(1) >= 0) & (macd < 0) & (df['low'] > lowerband) & ((df['close'] < fast_ema) | (df['close'] < slow_ema)) df['Long_Signal'] = np.where(long_condition, True, False)