If your backtest uses swing highs and lows, check when you mark them
A swing low is not a swing low until some bars have closed after it. If your code marks it on the bar it forms, every entry that references that level has already seen the future.
Mine did exactly that. Two bars. The equity curve was something I wanted to frame. Moved the marking to the bar where the swing is actually confirmed and the same rules, same data, same costs went negative.
One line. If you have never checked yours, that is where I would look first.