Double Bollinger Bands (DBB) for ThinkorSwim

chewie76

Well-known member
VIP
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.

PcFwceH.png


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

4TclXcN.png


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

GM70FeA.png


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.

tEthb1c.png


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".

LiPHVR7.png


Here is the Code:
Code:
#Double Bollinger Bands
#Assembled by Chewie76 on UseThinkscript.com
#[URL]https://usethinkscript.com/threads/double-bollinger-bands-dbb.4293/[/URL]

#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));
MidLine.SetDefaultColor(Color.YELLOW);
MidLine.SetLineWeight(2);
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));
UpperBand138.SetDefaultColor(GetColor(0));
LowerBand138.SetStyle(Curve.LONG_DASH);
UpperBand138.SetStyle(Curve.LONG_DASH);

#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;
UpperBand2.SetDefaultColor(GetColor(0));
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;
LowerBand3.SetDefaultColor(GetColor(0));
UpperBand3.SetDefaultColor(GetColor(5));
LowerBand3.SetDefaultColor(Color.GREEN);
UpperBand3.SetDefaultColor(Color.RED);
LowerBand3.SetLineWeight(2);
UpperBand3.SetLineWeight(2);


#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));
MidLine_short.SetDefaultColor(Color.YELLOW);
MidLine_short.SetLineWeight(2);
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));
UpperBand138_short.SetDefaultColor(GetColor(0));
LowerBand138_short.SetStyle(Curve.LONG_DASH);
UpperBand138_short.SetStyle(Curve.LONG_DASH);

#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;
UpperBand2_short.SetDefaultColor(GetColor(0));
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;;
LowerBand3_short.SetDefaultColor(GetColor(0));
UpperBand3_short.SetDefaultColor(GetColor(5));
LowerBand3_short.SetDefaultColor(Color.GREEN);
UpperBand3_short.SetDefaultColor(Color.RED);
LowerBand3_short.SetLineWeight(1);
UpperBand3_short.SetLineWeight(1);

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:
http://tos.mx/QKl2U7J
 
Last edited:

Stanley

New member
How do you trade that ? Going long when price is touching lowest band on 1 hr and 5min chart hoping for rebound ?
 

chewie76

Well-known member
VIP
VIP Enthusiast
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.

6sqaekm.png
 

chewie76

Well-known member
VIP
VIP Enthusiast
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.
1jPcMNG.png
 

chewie76

Well-known member
VIP
VIP Enthusiast
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.
HiVaxzk.png
 

Stanley

New member
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:

QUIKTDR1

Member
VIP
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;
 

rad14733

Well-known member
VIP
Ruby:
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... 💡
 

Marcoxiii

New member
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).
 

rad14733

Well-known member
VIP
@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...


Vtl2RCV.png
 
Last edited:

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.
Top