@eff I think that the issue might be in next where you are referencing past values such as self.histo.lines.histo[1] and self.stock.lines.percD[2] which may not exist yet in the first couple of calls to next.

I tried adding a line in your strategy's init method to force warming up long enough so those historical points would be valid and I no longer get an exception:

self.highest = bt.indicators.Highest(30)

A cleaner way would be to check the length of those indicators at the entry point to next and returning if they aren't ready.