Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
syntax error if elif statement

im getting an error that reads invalid syntax on the if statement.

price_history = history(bar_count=100, frequency='1h', field='price')
timeframe = price_history[context.security]

ema8 = talib.EMA(timeframe, timeperiod=14)[0]  
ema21 = talib.EMA(timeframe, timeperiod=21)[0]  
ema34 = talib.EMA(timeframe, timeperiod=34)[0]  
ema55 = talib.EMA(timeframe, timeperiod=55)[0]  
ema89 = talib.EMA(timeframe, timeperiod=89)[0]  
ema200 = talib.EMA(timeframe, timeperiod=200)[0]  

if ema8 < 'price' and ema 21 < ema8 and ema34 < ema 21 and ema 55 < ema 34 and ema 89 < ema 55 and ema 200 < ema89:  
    Trend = 1  
elif ema8 > 'price' and ema 21 > ema8 and ema34 > ema 21 and ema 55 > ema 34 and ema 89 > ema 55 and ema 200 > ema89:  
    Trend = -1  
else:  
Trend = 0

what did i mess up?

1 response

i fixed the spaces that are between the variable names. but it still says syntax error. not sure whats wrong.