Please provide the source code you want to modify or the name of a built-in study included in Thinkorswim. We are not going to create this from scratch.
Edit: The source code for this request was provided in the comment section below. So I can now provide the solution that was requested.
input price = close;
input deviations = 2.0;
input fullRange = yes;
input length = 21;
def regression;
def stdDeviation;
if (fullRange) {
regression = InertiaAll(price);
stdDeviation = stdevAll(price);
} else {
regression = InertiaAll(price, length);
stdDeviation = stdevAll(price, length);
}
plot upperLine = regression + deviations * stdDeviation;
plot middleLine = regression;
plot lowerLine = regression - deviations * stdDeviation;
upperLine.DefineColor("Up", Color.GREEN);
upperLine.DefineColor("Down", Color.RED);
upperLine.AssignValueColor(if upperLine > upperLine[1] then upperLine.Color("Up") else upperLine.Color("Down"));
middleLine.SetDefaultColor(GetColor(8));
middleLine.DefineColor("Up", Color.GREEN);
middleLine.DefineColor("Down", Color.RED);
middleLine.AssignValueColor(if middleLine > middleLine[1] then middleLine.Color("Up") else middleLine.Color("Down"));
lowerLine.SetDefaultColor(GetColor(8));
lowerLine.DefineColor("Up", Color.GREEN);
lowerLine.DefineColor("Down", Color.RED);
lowerLine.AssignValueColor(if lowerLine > lowerLine[1] then lowerLine.Color("Up") else lowerLine.Color("Down"));