I'm struggling, hoping someone can help.
This is inside a scheduled function. The bar_count is high because frankly nothing lower is working. When I access ema9[s][-1] I get nan. In fact, most the ema9[s] is nan except for a few bars somewhere in the middle.
Can you not run indicators based off resampled history data?
def OnFiveMinutes(context, data):
c = history(bar_count=5000,
frequency='1m',
field='close_price').resample('5min')
for s in context.stocks:
# Get EMA(9)
ema9 = c.apply(ExponentialMovingAverage,
length=9)