Terminology is important, so that we don't mistakenly convey something that is not accurate. So please allow me to explain the correct terminology which describes the solution I have provided below.
This solution is NOT a "watchlist filter". The term "watchlist filter" implies that it would be able to select specific ticker symbols to add to the watchlist, adding and removing ticker symbols as the filter criteria is processed. This solution is for a custom watchlist column, otherwise know as a "custom quote field" by the developers of Thinkorswim. It merely displays a value for each ticker symbol and changes color base on a comparison of two values.
After reading the source code you provided found it is computing the 30 period moving average of Daily volume. The code does this in a very clumsy way, but that is essentially what it is doing. The only reason I mention that is because the solution I provide below is radically different, yet it performs the same exact thing. I want to avoid any confusion for folks comparing your source code to my solution below.
When you apply this script to a custom column in your watchlist, the most important detail you need to account for is the time frame selected for your custom column. In this example, that time frame MUST be set to Daily. Otherwise, it will not give the same results as your source code.
Ok, here it is:
input percentThreshold = 200.0;
input averageLength = 30;
def volumeAverage = Average(volume[1], averageLength);
plot percentOfAverage = Round((volume / volumeAverage) * 100, 0);
percentOfAverage.AssignValueColor(if percentOfAverage > 100 then Color.BLACK else Color.CURRENT);
AssignBackgroundColor(if percentOfAverage > percentThreshold then Color.GREEN else if percentOfAverage >= 100 then Color.ORANGE else Color.CURRENT);
You will see I included two parameters which you can adjust. The first allows you to select the threshold level at which columns will change from orange to green. The second allows you to adjust the value used to compute the average daily volume.