Keltner channel/ Bollinger Band Cloud

A

arod49

New member
Does anyone know how to add a custom color cloud to fill in the Bollinger Band/Keltner Channel? thanks
 
BenTen

BenTen

Administrative
Staff
VIP
Try this:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2019
#

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(UpperBand, Midline, Color.Green, Color.Green);
AddCloud(LowerBand, Midline, Color.Red, Color.Red);
 
Last edited:
army11b1980

army11b1980

New member
VIP
@BenTen This is great! Is there a way to make the cloud change colors? Like green when price is above mid line and red for below?
 
BenTen

BenTen

Administrative
Staff
VIP
@army11b1980 Sure, code above has been updated.
 
L

Liquidity

New member
VIP
Anyone have/able to create something like the TradingView Bollinger Bands so that is has the cloud look to it? I found one deep on reddit but it was shaded red/green and couldn’t change the colors.
 
Top