• Get $40 off VIP by signing up for a free account! Sign Up

Double Bollinger Bands (DBB) for ThinkorSwim


Well-known member
VIP Enthusiast
The Double Bollinger Band (DBB) shows a long length and short length Bollinger Band. This is helpful for when you want to view a shorter timeframe, like a 30 min chart, and you would like to see what the Bollinger Band also looks like on the 4 hour chart. This gives you a short term and long term perspective on one chart.

FYI, default aggregation period is 4 hour. NOTE: This indicator will only display on timeframes that are equal to or less than the aggregation period.

The below picture is an example of the wider Bollinger Band as 4 hour and the smaller Bollinger Band as 30 minutes.


Here is an example of the long term 1 hour and short term 5 minute.


Here is an example of the long term 10 min and short term 1 minute.


FYI, these Bollinger Bands have 1, 2, and 3 standard deviation solid lines. The dashed lines are 1.38 standard deviation.

In the below example of AAPL, if you are trading the 15 min chart, look at how price bounces off the 4 hour bands. You could short when it breaks below the yellow 4 hour and your target would be the light green 1 st dev which is circled in yellow below. In this example, the long length is 180, and on the 15 min chart the short length is 50. I like using this setting.


In the settings shown below, you can change the length of the longer and shorter timeframes. You can change the aggregation period of the longer length so that it will stay that length on any chart that is less or equal to that time. If you want to take the short length off your chart, select "no".


Here is the Code:
#Double Bollinger Bands
#Assembled by Chewie76 on UseThinkscript.com

#1 st dev
input price = close;
input long_length = 180;
input aggregationPeriod = AggregationPeriod.FOUR_HOURS;
input short = yes;
input short_length = 50;
input averageType = AverageType.SIMPLE;
def displace = 0;

#180 Length
def Num_Dev_Dn = -1.0;
def Num_Dev_up = 1.0;
def price1 = close(period = aggregationPeriod);
def sDev = StDev(data = price1[-displace], length = long_length);
plot MidLine = MovingAverage(averageType, data = price1[-displace], length = long_length);
plot LowerBand1 = MidLine + Num_Dev_Dn * sDev;
plot UpperBand1 = MidLine + Num_Dev_up * sDev;
LowerBand1.SetDefaultColor(CreateColor(153, 255, 153));
UpperBand1.SetDefaultColor(CreateColor(255, 153, 51));

#1.38 st dev
def Num_Dev_Dn138 = -1.38;
def Num_Dev_up138 = 1.38;
plot LowerBand138 = MidLine + Num_Dev_Dn138 * sDev;
plot UpperBand138 = MidLine + Num_Dev_up138 * sDev;
LowerBand138.SetDefaultColor(CreateColor(105, 205, 255));

#2 st dev
def Num_Dev_Dn2 = -2.0;
def Num_Dev_up2 = 2.0;
plot LowerBand2 = MidLine + Num_Dev_Dn2 * sDev;
plot UpperBand2 = MidLine + Num_Dev_up2 * sDev;
LowerBand2.SetDefaultColor(CreateColor(105, 205, 255));

#3 st dev
def Num_Dev_Dn3 = -3.0;
def Num_Dev_up3 = 3.0;
plot LowerBand3 = MidLine + Num_Dev_Dn3 * sDev;
plot UpperBand3 = MidLine + Num_Dev_up3 * sDev;

#Short Length
def sDev_short = StDev(data = price[-displace], length = short_length);
plot MidLine_short = if short then MovingAverage(averageType, data = price[-displace], length = short_length) else double.nan;
plot LowerBand1_short =  if short then MidLine_short + Num_Dev_Dn * sDev_short else double.nan;
plot UpperBand1_short = if short then MidLine_short + Num_Dev_up * sDev_short else double.nan;
LowerBand1_short.SetDefaultColor(CreateColor(153, 255, 153));
UpperBand1_short.SetDefaultColor(CreateColor(255, 153, 51));

#1.38 st dev
plot LowerBand138_short = if short then MidLine_short + Num_Dev_Dn138 * sDev_short else double.nan;
plot UpperBand138_short = if short then MidLine_short + Num_Dev_up138 * sDev_short else double.nan;
LowerBand138_short.SetDefaultColor(CreateColor(105, 205, 255));

#2 st dev
plot LowerBand2_short = if short then MidLine_short + Num_Dev_Dn2 * sDev_short else double.nan;
plot UpperBand2_short = if short then MidLine_short + Num_Dev_up2 * sDev_short else double.nan;
LowerBand2_short.SetDefaultColor(CreateColor(105, 205, 255));

#3 st dev
plot LowerBand3_short = if short then MidLine_short + Num_Dev_Dn3 * sDev_short else double.nan;;
plot UpperBand3_short = if short then MidLine_short + Num_Dev_up3 * sDev_short else double.nan;;

AddCloud(UpperBand3, UpperBand2, Color.dark_RED, Color.CURRENT);
AddCloud(LowerBand2, LowerBand3, Color.dark_GREEN, Color.CURRENT);

AddCloud(UpperBand3_short, UpperBand2_short, Color.dark_RED, Color.CURRENT);
AddCloud(LowerBand2_short, LowerBand3_short, Color.dark_GREEN, Color.CURRENT);

Here is the link:
Last edited:

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

How do you trade that ? Going long when price is touching lowest band on 1 hr and 5min chart hoping for rebound ?
How do you trade that ? Going long when price is touching lowest band on 1 hr and 5min chart hoping for rebound ?
There are many ways you could trade this...depends on your style of trading. I personally am looking for price that is outside the 2 st dev to cross the 1.38 dashed line heading towards the center line. Could be considered a scalp trade. Here is an example.

You may want to look at a 4 hour chart and have the 180 length and the 50 length. Notice on the shorter 50 length highlighted. You may want to be bullish over the 50 and bearish under the 50.
You may be trading on the 15 minute chart, but want to see what the 4 hour looks like, so here is an example. Trade when it breaks the 4 hour lines.
Interesting thanks for your info . There is similar concept of trading on website by Erick using MOBO bands . Using day and 1 hr or 4 hr and 5min chart for spy trading . You trade in direction of higher time frame when higher is positive and lower going from negative to positive . You can see that on YouTube Liquid Options run by Erick its MOBO trading strategy .
Last edited:
Help! Help!

What is wrong with this code?

# check for open below EMA 8, 13, and 21

def openBelow = open < EMA8 and open < EMA13 and open < EMA 21;
def openBelow = if open < EMA8 and open < EMA13 and open < EMA21 then 1 else Double.NaN;

Also notice that there should be no white space between EMA and 21... 💡
Does any one know how to create Double Bollinger band strategy scanner?

Here are the details:
  • Narrow Bollinger band is (20 period, 2 SD)
  • Wide Bollinger band (10 period, 2.5 SD)
I would like the scanner to detect when the narrow (20,2) is completely inside the wide (10,2.5).
@Marcoxiii Similar to how TTM_Squeeze works using Bollinger Bands and Keltner Channels...??? You can experiment using two copies of the standard Bollinger Band Study and editing the settings for starters... If you find that it works as expected it could then be coded into a single study... Like below...

Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
340 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.