Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Need help with Bollinger Bands Algorithm

I am having trouble with my strategy and why it isn't selling at the upper band. Any help on how to fix this would be great.
Thanks

4 responses
if (sma_20 > sma_50, price <= lower_band):  

I don't know a case where you would use a comma in such a statement, but it doesn't do what you expect since it seems to be always true.
See what happens if you write

if (5 < 4, 3 >= 6):  
    print('5 < 4, 3 >= 6')

Replace the comma with 'and' in both conditions

if (sma_20 > sma_50 and price <= lower_band):  

Thanks for the help, but I am still having trouble with the algorithm selling the security.

The thing is that your conditions aren't met very often in that time. However, it also does go short. In this version I only added some prints and plots to see long/short positions. You can see in december it flips from long to short

Thanks, do you know if the Bollinger Bands are too large for the conditions to be met often.