Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Basically trying to buy when close_price is <= Lower Band and sell when close-price reaches SMA 20 day. Could anyone please help?

I'm newer to Quantopian and Python. I have the attached dataframe and chart. I want to calculate returns based on (Close Price = SMA 20) - previous (Close Price Below Lower Band = True). How can I set this up in the dataframe? Basically trying to buy when close_price is <= Lower Band and sell when close-price reaches SMA 20 day. Could anyone please help?

2 responses

Seem like I need to add a dataframe column which lists prices alongside True values (for below lower band) that are >= unhsma20. This way I can calculate and aggregate the returns.

but the dates would obviously be different