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

rad14733

Well-known member
VIP
@BenTen The AddCloud() lines only paint the top and bottom different colors, not trending colors... I've been working on a BollingerBand indicator and haven't been able to make the cloud paint properly... I tried looking at MomentumKeltnerChannels by @Pensar but my brain just isn't in the game this evening... Banged my head earlier and must have jarred some dust loose in there... Any help would be greatly appreciated...
 
BenTen

BenTen

Administrative
Staff
VIP
@rad14733 I believe you can only assign one color to each cloud. Is that what you were asking about?
 
rad14733

rad14733

Well-known member
VIP
@rad14733 I believe you can only assign one color to each cloud. Is that what you were asking about?
No... MomentumKeltnerBands does trending colors, UpTrend and DownTrend... The issue is the BollingerBands and KeltnerChannels never do a crossover so the code needs to be faked out into trending... I've been plugging away at it... If I figure it out I'll post my findings, but if anyone has a fix for this I'd greatly appreciate it because then I can move on to other things...
 
BenTen

BenTen

Administrative
Staff
VIP
@rad14733 The Bollinger Bands will expand along as price continues its uptrend or downtrend, so it's definitely different from the MomentumKelterBands. With the MomentumKelterBands, the price can move far away from it in either direction.
 
rad14733

rad14733

Well-known member
VIP
@rad14733 The Bollinger Bands will expand along as price continues its uptrend or downtrend, so it's definitely different from the MomentumKelterBands. With the MomentumKelterBands, the price can move far away from it in either direction.
Yep... And I'm working on a "Skinny_BollingerBands" study at the moment... I just found a BB script that changes trend colors so now I just need to figure out how they did it and replicate the logic in my study... My logic on this is to have a variable noise zone for less false entries... Just an idea I had and felt the need to play with...

Edited to add: Actually, the code I found was the FW_MOBO code that @Pensar used in MomentumKelterBands...
 
Last edited:

Similar threads

Top