@Tomas
I am also new to Backtrader and I got the same issue.
I tried to check the code and did the following changes to work:
Add a MovingAverageSimple indicator
self.sma = bt.indicators.SimpleMovingAverage(self.datas[0].close, period = self.params.myperiod)
or
self.sma = bt.indicators.SimpleMovingAverage(self.dataclose, period = self.params.myperiod)
Good luck!