It looks like there is look-ahead introduced here. When using external daily data you have to shift all the values forward by one trading day if you're using the 'Close' field, otherwise you introduce bias. You could use the 'Open' field, but that data isn't posted until the end of the day either so it's still not a good idea.
I see you add a new row for the next trading day with a copy of the last data point, which I assume is so you can use it paper/live trading. That operation should sound an alarm that you need to shift all previous observations forward to match how you'd have to do it in the live scenario.
Here is the same algo using the open price rather than the close, it technically does not have look-ahead in this backtest, but this still wouldn't be possible in live trading.