Standard Deviation Bands Enhanced for ThinkorSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

This is my new favorite indicator. I like it on 2 min chart.

6oUXClm.png
Curious to ask, what MA is that you have that changes color with the trend?
 
This is my new favorite indicator. I like it on 2 min chart.

6oUXClm.png
Hi Chewy, just scrolling through the post and I noticed you went from this being your "new favorite indicator" in May of 2021, to using "Elastic Stochastic". Was there a reason for the switch? Thanks!
 
I came back to this indicator after I made a few tweaks. Changed length to 100 and used 0.78 and 2 for the colored bands. I noticed in a strong up or down trend, the price will stay inside the colored bands as highlighted in the picture. I also noticed that when there is a break of trend, price will sometimes come back to test the opposite band highlighted twice with arrows in below picture. I also adjusted the Midline to change color to red/green when trending and gray when flat. I added a 3 st. dev. dark gray line that shows extreme strength and often times results in immediate reversal.

1720892100859.png


Code:
# Enhanced Standard Deviation Bands by Horserider 9/21/2019
# Two standard TD Ameritrade IP Company, Inc. (c) 2019 StandardDeviation studies combined into one study with deviations being 1.3 and 2.0 . User changeable length, dev, and avg type to suit their trading.

# Inner bands
input length = 100; #20
input numDevDn = -1.00;
input numDevUp = 1.00;
input averageType = AverageType.EXPONENTIAL;

def avg = MovingAverage(averageType, close);
def expDev = ExpAverage(AbsValue(avg - close), length);

plot UpperBand = avg + numDevUp * expDev;
plot MidLine = avg;
plot LowerBand = avg + numDevDn * expDev;

UpperBand.SetDefaultColor(color.gray);
MidLine.SetLineWeight(2);
LowerBand.SetDefaultColor(color.gray);

def vwma8 = Sum(volume * close, 8) / Sum(volume, 8);
def vwma19 = Sum(volume * close, 19) / Sum(volume, 19);
def bullish = if vwma8 > vwma19  then 1 else 0;
def bearish = if vwma8 < vwma19 then 1 else 0;

midline.AssignValueColor(if bearish and close <= midline then Color.RED else if bullish and close >= midline then Color.GREEN
else Color.LIGHT_GRAY);


# Outer bands

input numDevDnob = -2.0;
input numDevUpob = 2.0;
input averageTypeob = AverageType.EXPONENTIAL;

def avgob = MovingAverage(averageTypeob, close);
def expDevob = ExpAverage(AbsValue(avgob - close), length);

plot UpperBandob = avgob + numDevUpob * expDevob;
plot LowerBandob = avgob + numDevDnob * expDevob;

UpperBandob.SetDefaultColor(GetColor(1));
LowerBandob.SetDefaultColor(GetColor(1));
UpperBandob.SetLineWeight(1);
LowerBandob.SetLineWeight(1);

# Clounds for areas of possible reversals. Green for longs, red for shorts.
AddCloud( upperband,upperbandob, Color.dark_red, Color.dark_red);
AddCloud( lowerband,lowerbandob, Color.dark_green,color.dark_green);

# OuterLAST bands

input numDevDnob1 = -3.0;
input numDevUpob1 = 3.0;


def avgob1 = MovingAverage(averageTypeob, close);
def expDevob1 = ExpAverage(AbsValue(avgob - close), length);

plot UpperBandob1 = avgob + numDevUpob1 * expDevob;
plot LowerBandob1 = avgob + numDevDnob1 * expDevob;

UpperBandob1.SetDefaultColor(color.dark_gray);
LowerBandob1.SetDefaultColor(color.dark_gray);
UpperBandob1.SetLineWeight(2);
LowerBandob1.SetLineWeight(2);
 
Last edited by a moderator:
I know its been quite so time since this post, but maybe you can give me a hand if its possible to plot a higher aggregation period on smaller time frames for the following indicator:

https://usethinkscript.com/threads/standard-deviation-bands-enhanced-for-thinkorswim.680/

I intent to use the 1H Volatility Box/clouds of this indicator into the 1m and/or 3m timeframe.

Thanks, I really appreciate any approach.

MTF Multi-TimeFrame Standard Deviation Bands
SnqM6ur.png

Ruby:
# MTF Multi-Timeframe Version
# Enhanced Standard Deviation Bands by Horserider 9/21/2019
# Two standard TD Ameritrade IP Company, Inc. (c) 2019 StandardDeviation studies      combined into one study with deviations being 1.3 and 2.0 . User changeable length, dev, and avg type to suit their trading.
#
# Inner bands
input agg = AggregationPeriod.HOUR;
def src = close(period = agg);
input length = 20;
input numDevDn = -1.3;
input numDevUp = 1.3;
input averageType = AverageType.EXPONENTIAL;

def avg = MovingAverage(averageType, src);
def expDev = ExpAverage(AbsValue(avg - src), length);

plot UpperBand = avg + numDevUp * expDev;
plot MidLine = avg;
plot LowerBand = avg + numDevDn * expDev;

UpperBand.SetDefaultColor(GetColor(1));
MidLine.SetDefaultColor(GetColor(1));
MidLine.SetStyle(Curve.SHORT_DASH);
LowerBand.SetDefaultColor(GetColor(1));

# Outer bands
input lengthob = 20;
input numDevDnob = -2.0;
input numDevUpob = 2.0;
input averageTypeob = AverageType.EXPONENTIAL;

def avgob = MovingAverage(averageTypeob, src);
def expDevob = ExpAverage(AbsValue(avgob - src), lengthob);

plot UpperBandob = avgob + numDevUpob * expDevob;
#plot MidLineob = avgob;
plot LowerBandob = avgob + numDevDnob * expDevob;

UpperBandob.SetDefaultColor(GetColor(1));
#MidLineob.SetDefaultColor(GetColor(1));
#MidLineob.SetStyle(Curve.SHORT_DASH);
LowerBandob.SetDefaultColor(GetColor(1));


# Clouds for safe zones Light gray for long, dark gray for short.
AddCloud (midline,upperbandob, Color.lIGHT_GRAY, Color.lIGHT_GRAY);
AddCloud(midline, lowerband, Color.GRAY, Color.GRAY);

# Clounds for areas of possible reversals. Green for longs, red for shorts.
AddCloud( upperband,upperbandob, Color.LIGHT_RED, Color.LIGHT_RED);
AddCloud( lowerband,lowerbandob, Color.LIGHT_GREEN, Color.LIGHT_GREEN);

# Plot arrows for src crosses of Deviation lines. Indside plum, Outside red/green Arrows included because many like arrows. I suggest being careful following any arrow signal.
plot UpSignalob =  src crosses below   lowerbandob ;
plot DownSignalob = src crosses above upperbandob;

plot UpSignal =  src crosses   lowerband ;
plot DownSignal = src crosses  upperband;

UpSignal.SetDefaultColor(Color.PLUM);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.PLUM);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

UpSignalob.SetDefaultColor(Color.UPTICK);
UpSignalob.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignalob.SetDefaultColor(Color.DOWNTICK);
DownSignalob.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
356 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top