I have modified a template algorithm to get my first experiences on quantopian.
The idea was to enter on momentum and ONLY if there is no current position(context.portfolio.positions_value == 0) and then sell when price moves into negative momentum. Logically it follows that there can never be two buys without a sell in between - and this is what shows when i write to log from my if/else-function. However when I run a full backtest and show transactions multiple sequences of 'buy buy buy' and 'sell sell sell' show up. I am only using the 'order' command in this loop, so the log should show the same as the transaction overview.
Can anyone go through it and spot what causes this?