Ok, so for context, the video you mentioned was for a custom watchlist column, not a scan. That video is here: https://www.hahn-tech.com/thinkorswim-ttm-squeeze-watchlist/
Instead of a watchlist, you want to scan for the number of red dots on the TTM Squeeze. The code for watchlists and scans is very similar. They are easily converted. We have done this for a watchlist here: https://www.hahn-tech.com/thinkorswim-watchlist-ttm-squeeze/
So we’ll adapt that code to work as a scan:
input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
def squeezeDots = TTM_Squeeze(price, length, nK, nBB, alertLine).SqueezeAlert;
# the original code here counted the number of green dots, so we comment this out and leave it here for safe-keeping
#def alertCount = if squeezeDots[1] == 0 and squeezeDots == 1 then 1 else if squeezeDots == 1 then alertCount[1] + 1 else 0;
# and here we have modified it to count the red dots
def alertCount = if squeezeDots[1] == 1 and squeezeDots == 0 then 1 else if squeezeDots == 0 then alertCount[1] + 1 else 0;
# alertCount is the variable that keeps track of our red dots
# we can scan for greater than 3 consecutive red dots
plot scan = alertCount > 3;
# or we can scan for a range of dots, 1-3
#plot scan = alertCount > 0 and alertCount < 4;