Within my algorithm, I have developed a rolling window where the algorithm trades based off an indicator. I understand that the last piece of that indicator says that if the price is higher than the previous day's close, buy 100 shares. Once the algorithm does that, it will not trade again unless the profit taking % is hit or the stop loss is hit. What I ultimately want for my algorithm is for it to be able to buy 100 shares every time the indicator is triggered, whether I am invested or not. Right now it limits me if I am already invested, to not invest again. If I take out the self.portfolio.notinvested, the algorithm will trade over 100 times and I understand that is because my indicator is dependent on one price being higher than the other. Does anyone know a way to just trade that one time for 100 shares, and if the indicator is triggered again (even if I am already invested), it will invest in 100 more shares? I have tried to write the last part as self.Securities[AAPL].Price == .50 + self.Window[0].Close, but I know that is way too specific and it does not work. Does anyone know any other ways? If you need clarification, please let me know.

Author