# Bollinger Band trend indicator

A

#### Aliikhatami

##### New member
VIP
Hey @BenTen ,
Im looking for an edit to Bollinger band indicator. so statistically speaking, bollinger bands show you how far the price is moving from its moving averages and thats based on standard deviations which shows the statistical significance of that price level. so based on that you know how likley it is for the price action is to stay there and as if its gonna start moving closer to its average and eventually reverse. so with that I have been using 2 bollinger bands with std of 1 and another with std of 2.5. I short the future or stock when its below its 10 and 20 moving averages and also crossing below 1std from BBand with 10 moving average and start covering my position and trimming when it reaches the 2.5 standard deviation and taking profits. that being said, to make it easer to recognize the entry i was looking for a version of BBands that highlights the area between the 2 upper bands and 2 lower bands of 2 BBands with one being standard deviation of 1 and another 2.5. please let me know if thats possible. thank you!

entry example on 1h chart of /es:

Last edited by a moderator:

#### BenTen

Staff
VIP
Is this what you're looking for?

Code:
``````# Bollinger Bands with Cloud
# TD Ameritrade IP Company, Inc. (c) 2007-2020
#

input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;

def sDev = stdev(data = price[-displace], length = length);

plot MidLine = MovingAverage(averageType, data = price[-displace], length = length);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;

LowerBand.SetDefaultColor(GetColor(0));
MidLine.SetDefaultColor(GetColor(1));
UpperBand.SetDefaultColor(GetColor(5));

AddCloud(Midline, UpperBand, color.green, color.green);
AddCloud(Midline, LowerBand, color.red, color.red);``````

A

#### Aliikhatami

##### New member
VIP
so if you can add another bollinger band with sd of 1 and only highlight the area between the 2 upperS and 2 lowerS then would be perfect! @BenTen
area around moving average should be empty and not highlighted

Last edited:
A

#### Aliikhatami

##### New member
VIP
@horserider not this. its a different strategy. i got it to work though. i highlighted the 1std and that keeps the outer area unhighlighted. love it. thank you

#### BenTen

Staff
VIP
@Aliikhatami Here you go:

Code:
``````#
# Double Bollinger Bands
# Assembled by BenTen at useThinkScript.com
# Based on request/concept of @aliikhatami

input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn1 = -1.0;
input Num_Dev_up1 = 1.0;
input Num_Dev_Dn3 = -3.0;
input Num_Dev_up3 = 3.0;
input averageType = AverageType.EXPONENTIAL;

def sDev = stdev(data = price[-displace], length = length);

plot MidLine = MovingAverage(averageType, data = price[-displace], length = length);
plot LowerBand1 = MidLine + num_Dev_Dn1 * sDev;
plot UpperBand1 = MidLine + num_Dev_Up1 * sDev;
plot UpperBand3 = MidLine + num_Dev_Up3 * sDev;
plot LowerBand3 = MidLine + num_Dev_Dn3 * sDev;

AddCloud(UpperBand1, UpperBand3, color.green, color.green);
AddCloud(LowerBand1, LowerBand3, color.red, color.red);``````

A

#### Aliikhatami

##### New member
VIP
thank you so much man this is AWESOME!