Standard Deviation Channels X3 For ThinkOrSwim

M_Morisette

New member
2. Simple but effective.
3. Reversion to the mean.

Code:
``````#
## Title: Standard Deviation Channels x3
## Author: Matt Morisette
## Date: 1/19/2022
## Original Study: TDA StandardDevChannel
#

## GLOBAL START ##
input price = close;
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 MiddleLine = regression;
MiddleLine.SetDefaultColor(CreateColor(255, 236, 74));
MiddleLine.SetStyle(Curve.SHORT_DASH);
## GLOBAL END ##

## DEVIATION 1 ##
input deviation_1 = 1.0;
plot upperLine_1 = regression + deviation_1 * stdDeviation;
plot lowerLine_1 = regression - deviation_1 * stdDeviation;
upperLine_1.SetDefaultColor(CreateColor(255, 1, 154));
lowerLine_1.SetDefaultColor(CreateColor(255, 1, 154));

## DEVIATION 2 ##
input deviation_2 = 2.0;
plot upperLine_2 = regression + deviation_2 * stdDeviation;
plot lowerLine_2 = regression - deviation_2 * stdDeviation;
upperLine_2.SetDefaultColor(CreateColor(255, 249, 202));
lowerLine_2.SetDefaultColor(CreateColor(255, 249, 202));
upperLine_2.SetStyle(Curve.SHORT_DASH);
lowerLine_2.SetStyle(Curve.SHORT_DASH);

## DEVIATION 3 ##
input deviation_3 = 3.0;
plot upperLine_3 = regression + deviation_3 * stdDeviation;
plot lowerLine_3 = regression - deviation_3 * stdDeviation;
upperLine_3.SetDefaultColor(CreateColor(255, 129, 205));
lowerLine_3.SetDefaultColor(CreateColor(255, 129, 205));``````

Examples

Settings

I would like to find a Standard Deviation scan that would give me all the stocks that are currently above the + 2.5 stan. dev. line or below the -2.5 stan dev line. I've only found one written 4 years ago, however it gives zero stocks

I would like to find a Standard Deviation scan that would give me all the stocks that are currently above the + 2.5 stan. dev. line or below the -2.5 stan dev line. I've only found one written 4 years ago, however it gives zero stocks
input price = close;
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);
}
input deviation = 2.5;
plot upperLine = close >(regression + deviation * stdDeviation);
#plot lowerLine_3 = regression - deviation_3 * stdDeviation;

Really appreciate you responding.........too busy today, but I have all day tomorrow to get after it.........sammy

Not the exact question you're looking for?

87k+ Posts
385 Online

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?