Is it possible to define what standard deviation the BollingerBandWidth should be based upon in ProBackTest?
The code in ProBackTest is “BollingerBandWidth[x](close)” where X is the amount of periods used to calculate the bandwidth.
But I would also like to define the standard deviation the bandwidth is calculated with, is this possible?
For example: “BollingerBandWidth[20, 3](close) where 3 is the deviation.
There you go:
p = 20
m = 3
bbmid = average[p](close)
bbupper = bbmid + (std[p](close)*m)
bblower = bbmid - (std[p](close)*m)
bbwidth = bbupper - bblower
return bbwidth
Something to consider is calculating the bollinger band width as a percentage of the mid line value.
p = 20
m = 2
bbmid = average[p](close)
bbupper = bbmid + (std[p](close)*m)
bblower = bbmid - (std[p](close)*m)
bbwidth = bbupper - bblower
bbwidthperc = (bbwidth/bbmid)*100
return bbwidthperc
Thank you very much for the quick help Vonasi!