import pandas as pd
import numpy as np
import talib

data = pd.DataFrame({
'close': ,
'high': ,
'low':
})

rsi_period = 14
macd_fast_period = 12
macd_slow_period = 26
macd_signal_period = 9

rsi = talib.RSI(data, timeperiod=rsi_period)
macd, signal, _ = talib.MACD(data, fastperiod=macd_fast_period, slowperiod=macd_slow_period, signalperiod=macd_signal_period)

def combine_signals(rsi, macd):
signals =
for i in range(len(rsi)):
if rsi > 70 and macd > 0:
signals.append('Sell')
elif rsi < 30 and macd < 0:
signals.append('Buy')
else:
signals.append('Hold')
return signals

combined_signals = combine_signals(rsi, macd)

data = rsi
data = macd
data = combined_signals
print(data)
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.