Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Help with issue: Algorithm is buying and selling at the same time.

I'm trying to test an algorithm that buys or sells SPY when the latest close has crossed a simple moving average and rebalance weekly. In my backtest, it appears that the algorithm is just buying a position then instantly selling it each rebalance period. Can someone please help me with this?