NexusFi: Find Your Edge


Home Menu

 





Bollinger Band - Thinkscript question...


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one netarchitech with 3 posts (1 thanks)
    2. looks_two Oxmyx with 2 posts (0 thanks)
    3. looks_3 JayC with 2 posts (0 thanks)
    4. looks_4 rmejia with 1 posts (1 thanks)
    1. trending_up 11,104 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Bollinger Band - Thinkscript question...

  #1 (permalink)
netarchitech
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);

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Build trailing stop for micro index(s)
Psychology and Money Management
ZombieSqueeze
Platforms and Indicators
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
23 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #2 (permalink)
 
rmejia's Avatar
 rmejia 
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);

Reply With Quote
Thanked by:
  #3 (permalink)
netarchitech
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);

Reply With Quote
Thanked by:
  #4 (permalink)
 Oxmyx 
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.

Reply With Quote
  #5 (permalink)
netarchitech
NY, NY
 
Posts: 68 since Dec 2011
Thanks Given: 27
Thanks Received: 19

@Oxmyx Unfortunately, the answer is no...Addcloud() is definitely limited in that regard...More info below:

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddCloud

Good Luck and Good Trading

Reply With Quote
  #6 (permalink)
 JayC 
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

Reply With Quote
  #7 (permalink)
 Oxmyx 
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...

Reply With Quote
  #8 (permalink)
 JayC 
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.

Reply With Quote




Last Updated on May 29, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts