Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
SimpleMovingAverage Cross Help

Hi everyone,

I am trying to write my first algorithm, but I couldn't manage to get results so far. I am getting error for set_screen. And for the remaining of the code I am not quite sure I did right things. I am pasting the below, since I can't backtest the strategy. Sorry for the mess.
Any help, highlighting, criticism is welcome.

I want to buy a stock if the following conditions exist:
1- Price is over 200 simple moving average
2- 100 day simple moving average is above 200 simple moving average
3- Buy when 10 day simple moving average cross 100 day moving average above

Close the position(s) 10 day simple moving average cross 100 day simple moving average below.
I added the code.

5 responses

Show the algorithm/attach it then I can help better

Hi Jake. Thank you for your interest. I attached the algorithm as notebook because it doesn't allow me to attach it as backtest.

After reviewing your algorithm I believe the problem is an error in the pipeline how ever once you fix this you will have other bugs primarily because the algorithm has

prices = data.history(context.security_list, 'price', 1, '1d')

price = prices['price'][security]

I won't redo your algo for you but hopefully this helps

Thanks for help Jake. I am working on Research API hopefully I will develop better algorithms.

Good luck!