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:
Here is the link:
http://tos.mx/QKl2U7J
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:
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: