Include 1 and 2.5 deviations to Bollinger Bands

Aliikhatami

New member
VIP
I'm 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 that's based on standard deviations which shows the statistical significance of that price level. so based on that you know how likely 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 that's possible. thank you!

entry example on 1h chart of /ES:

Untitled.png
 
Last edited by a moderator:

BenTen

Administrative
Staff member
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);
 

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:

BenTen

Administrative
Staff member
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);
 

Brain Monkey

New member
Here is a slight tweak that makes the clouds translucent so they don't over take the screen.
Code:
#
# Double Bollinger Bands with translucent clouds.
# Assembled by BenTen at useThinkScript.com
# Based on request/concept of @aliikhatami
# Slightly touched up by some spitball no name.

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, createcolor(000, 090, 000), createcolor (000, 090, 000));

AddCloud(LowerBand1, LowerBand3, createcolor(100, 000, 000), createcolor (100, 000, 000));
 

Brain Monkey

New member
So I take 2 studies and overlap them. I set one cloud at 1 and 3 Std Dev and the second cloud I set at 2 and 3 Std Dev. Right now I only use it on my daily chart with 20 SMA.

qoxATQh.png
 

Similar threads

Top