Changin Quantization boundary dynamically


I need to change the speed at which a subscribed event happens. I wanted to get a random quant boundary and set it, but am not able to achieve this follwoing the logic above. Substantially 1 event triggers at bar, every 4 bars trigger a random gate output, trigger quant boundary value, then set subscribe again… any insights?