Volume x percent above average within last x bars


#Wizard text: Current bar’s
#Wizard input: price
#Wizard input: choice
#Wizard text: at least
#Wizard input: percent
#Wizard text: % from its typical average over
#Wizard input: length
#Wizard text: periods

input price = volume;
input choice = {default increased, decreased};
input percent = 20;
input length = 50;
def avg = average(price, length)[1];
def chg = 100*(price/avg -1);
plot scan;

switch (choice) {
case increased:
scan = chg >= percent;
case decreased:
scan = chg <= -percent;
}

This the study I pulled from TOS scan it is unusual volume when current’s bar increased at least 1000% from it typical average over 20 period.

But I want to modified it to any bar that reached 1000% no only the current’s bar.

Thank you