Instead of looking at daily data, I'd like to get the Open, High, Low, and Close of a stock on the weekly time interval. I'm trying to use this weekly price data to calculate the MACD as the crossover occur less often. Any ideas as to how to use weekly candlestick data to get MACD?
I have this so far:
if data.can_trade(sid(26807)):
daily_ohlc = data.history(sid(26807), ['open', 'high', 'low', 'close'], 5, '1d')
weekly_ohlc = daily_ohlc.resample('1W').agg({'open': 'first',
'high': 'max',
'low': 'min',
'close': 'last'})
macd_raw, signal, hist = talib.MACD(weekly_ohlc['close'], fastperiod=12,
slowperiod=26, signalperiod=9)
record(Raw = macd_raw, Signal = signal)
log.info("Weekly open for {0} is {1}".format(sid(26807).symbol, weekly_ohlc['close']))
The "weekly_ohlc" does return accurate values for weekly data. However, when plugging that into the MACD code it returns errors. How can I get the MACD based on the close prices of the weekly data?
Thanks