Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Bollinger Band - Thinkscript question...
Updated May 29, 2020
Top Posters
looks_one
netarchitech
with 3 posts (1 thanks)
looks_two
Oxmyx
with 2 posts (0 thanks)
looks_3
JayC
with 2 posts (0 thanks)
looks_4
rmejia
with 1 posts (1 thanks)
trending_up
11,104 views
thumb_up
2 thanks given
group
2 followers
forum
7 posts
attach_file
0 attachments
Bollinger Band - Thinkscript question...
January 10th, 2015, 09:23 AM
NY, NY
Posts: 68 since Dec 2011
Thanks Given: 27
Thanks Received: 19
I'm having trouble trying to programmatically add a custom colored "cloud"
a/k/a fill to a Bollinger Band study as highlighted below...
FYI, I was able to successfully change the fill the first time. However, after
that, the color would not change/revert no matter what I did...
Any help/assistance would be greatly appreciated. Thanks in advance...
declare upper;
input price = close;
input displace = 0;
input length = 20;
def sDev = stdev(data = price[-displace], length = length);
plot MidLine = Average(data = price[-displace], length = length);
MidLine.Hide();
MidLine.HideBubble();
#MidLine.setStyle(curve.SHORT_DASH);
#MidLine.SetDefaultColor(color.gray);
plot LowerBand = MidLine - 2 * sDev;
LowerBand.SetDefaultColor(color.gray);
plot UpperBand = MidLine + 2 * sDev;
UpperBand.SetDefaultColor(color.gray);
addCloud(LowerBand, UpperBand, color.gray);
#addCloud(LowerBand, UpperBand, color.RED);
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
January 10th, 2015, 06:57 PM
Puerto Rico
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441
@netarchitech Sometimes they work with just one color, I forget the specifics but I think clouds are made from 2 colors. So it would be:
addCloud(LowerBand, UpperBand, color.gray, color.gray);
January 10th, 2015, 08:19 PM
NY, NY
Posts: 68 since Dec 2011
Thanks Given: 27
Thanks Received: 19
@rmejia That did the trick! Thanks a million
In the hopes that this will help someone somewhere along the way, here's the final script:
declare upper;
input price = close;
input displace = 0;
input length = 20;
def sDev = stdev(data = price[-displace], length = length);
plot MidLine = Average(data = price[-displace], length = length);
MidLine.SetDefaultColor(color.gray);
MidLine.Hide();
MidLine.HideBubble();
plot LowerBand = MidLine - 2 * sDev;
LowerBand.SetDefaultColor(color.gray);
plot UpperBand = MidLine + 2 * sDev;
UpperBand.SetDefaultColor(color.gray);
addCloud(LowerBand, UpperBand, color.gray, color.gray);
May 25th, 2020, 05:21 PM
Denver + CO
Experience: Advanced
Platform: TradeStation
Trading: Guitar
Posts: 7 since Jun 2013
Thanks Given: 1
Thanks Received: 0
Thanks for the posted code, netarchitech. Was wondering if there's a way to make the cloud color an input. Currently I can change the colors of the upper and lower bands, but not the cloud itself without digging into the code to manually change it.
May 29th, 2020, 12:54 AM
San Diego, CA
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43
Color control is a bit limited, but there's a couple of things you could try.
This isn't great, as you don't get to use the color selector for the input, but the number is based on the color table.
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/GetColor
Code
input colorNum = 1;
AddCloud(LowerBand, UpperBand, GetColor(colorNum), GetColor(colorNum));
Another option is to use global color, as seen in this post, which allows you to adjust the color in the global section at the bottom of the properties window.
Regards,
JayC
May 29th, 2020, 12:47 PM
Denver + CO
Experience: Advanced
Platform: TradeStation
Trading: Guitar
Posts: 7 since Jun 2013
Thanks Given: 1
Thanks Received: 0
Thanks, JayC! That worked well! Now if I could just control the transparency...
May 29th, 2020, 01:01 PM
San Diego, CA
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43
I haven't seen any transparency control yet, but I'll keep my eye out.
Last Updated on May 29, 2020