moving_av1 = data[context.tsla].mavg(5)
moving_av2 = data[context.tsla].mavg(15)
current_price = data[context.tsla].price
cash = context.portfolio.cash
if moving_av2 > current_price:
#trading price is below the 15 day ma, looking for rebound
if moving_av1 > moving_av2:
#still pulling back, bearish crossover coming
pass
elif moving_av1 < moving_av2:
#buy, bearing crossover compelete, looking for entry on lowest MACDhist
if (((moving_av2)-(moving_av1))/(moving_av2) > .005
#MACD difference is greater than .5%, buy
#share calculation
**if current_price*10 > cash
print'not enough funds'
elif current_price*10 < cash
order(context.tsla, +10)**
elif (((moving_av2)-(moving_av1))/(moving_av2) < .005
#not good enough
pass
elif moving_av2 < current_price:
#trading price is above 15 day ma, looking for resistance
if moving_av1 > moving_av2:
#sell, bullish cross compelete, MACDhist gaining, resistance getting close
if (((moving_av2)-(moving_av1))/(moving_av2) > -.005
#MACD difference is greater than .5%, sell
#share calculation
*order(context.tsla, -10)*
elif (((moving_av2)-(moving_av1))/(moving_av2) < -.005
#not good enough
pass
elif moving_av1 < moving_av2:
#bullish cross coming, moving up
pass
Im getting an error syntax where the bold is at. not sure why!
Will it error out at the italics also then or no?
Also, if statements are linear, how would I look this function so that the orders happen every time the conditions are met and not just the first time? I've tried while and for statements but it errors out every time.
Thank you, anyone!