Breakout coding


I am trying to code dynamic breakout strategy. Which assigns day 1 look back period as 20 then based on volatility changes look back period changes. I was able to code change in volatility as below now i am stuck so as to how to link it with look back period.

vol1=STD(close(),30); vol2=STD(close()[1],30); delvol=(vol1-vol2)/vol1; plot1=delvol


The python code is as below

close = self.History(self.syl, 31, Resolution.Daily)[‘close’]
todayvol = np.std(close[1:self.numdays+1])
yesterdayvol = np.std(close[0:self.numdays])
deltavol = (todayvol - yesterdayvol) / todayvol
self.numdays = round(self.numdays * (1 + deltavol)) # the number of days must be integer

What function shall i use to create this nesting.