here's a simple 3x standard deviation channel watchlist column i put together – it changes colors depending on where a stock's close is. if it's above the regression line, labels signal when it's above a deviation. if it's below the regression line, labels signal when it's below another deviation. just note the timeframe you want is set at the top of the watchlist code window.
colors can be tweaked how you like. right now it signals anything above (green) or below (red) a 2nd deviation – everything else is gray.
Code:
#
# 3x standard deviation watchlist column
# @rough__sleeper
#
def price = close;
def fullRange = Yes;
def length = 21;
def regression;
def stdDeviation;
if (fullRange) {
regression = InertiaAll(price);
stdDeviation = stdevAll(price);
} else {
regression = InertiaAll(price, length);
stdDeviation = stdevAll(price, length);
}
def onedeviationUP = regression + 1 * stdDeviation;
def onedeviationDOWN = regression - 1 * stdDeviation;
def twodeviationUP = regression + 2 * stdDeviation;
def twodeviationDOWN = regression - 2 * stdDeviation;
def threedeviationUP = regression + 3 * stdDeviation;
def threedeviationDOWN = regression - 3 * stdDeviation;
AddLabel(1,
if close > threedeviationUP then " 3 Dev Up "
else if close < threedeviationDOWN then " 3 Dev Dn "
else if close > twodeviationUP then " 2 Dev Up "
else if close < twodeviationDOWN then " 2 Dev Dn "
else if close > onedeviationUP then " 1 Dev Up "
else if close < onedeviationDOWN then " 1 Dev Dn "
else if close > regression then " Reg Up "
else if close < regression then " Reg Dn "
else " "
,
Color.Black
);
#AssignBackgroundColor(if close > regression then Color.LIME else if close < regression then color.PINK else Color.BLACK);
AssignBackgroundColor(if close > twodeviationUP then Color.GREEN else if close < twodeviationDOWN then color.RED else if close > regression then Color.GRAY else if close < regression then color.GRAY else Color.BLACK);