Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How would i graph moving average 1, and moving average 2, in a chart?

def initialize(context):
schedule_function(myfunc, date_rules.every_day(), time_rules.market_open(minutes = 15))

def myfunc(context, data):
stk = symbol('AAPL')
Avg1 = data.history(stk, 'price', 10,'1d').mean()
Avg2 = data.history(stk, 'price', 30,'1d').mean()
current_positions = context.portfolio.positions[stk].amount
if (Avg1 > Avg2) and current_positions == 0:
order_target_percent(stk, 0.25)
elif (Avg1 < Avg2) and current_positions != 0:
order_target(stk, 0)

1 response
record(Avg1 = Avg1, Avg2 = Avg2)