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)
Need MACDBBLines for ThinkorSwim
Updated February 20, 2021
trending_up
2,591 views
thumb_up
1 thanks given
group
2 followers
forum
3 posts
attach_file
2 attachments
Need MACDBBLines for ThinkorSwim
June 10th, 2020, 08:46 AM
Weston, Florida, USA
Experience: Advanced
Platform: Ninja Trader
Trading: ES, CL, TF, 6E, GC
Posts: 47 since Oct 2010
Thanks Given: 49
Thanks Received: 49
Good morning to all, I was looking for the MACDBBLines for Thinkorswim platform, would any of you be so kind to point me in the right direction where to find it? Thanks
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
June 11th, 2020, 09:23 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
Never seen MACDBBLines before, so this might be completely wrong. Also, this mostly just copy paste from the built-in versions of MACD and BB. I replaced the average line in MACD with BB lines. If you can provide more specific requirements, I can customize it further if you need.
JaycC
Code
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = yes;
plot MACD = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot BB = BollingerBands(price = MACD, length = MACDLength, "average type" = averageType).MidLine;
plot BBUpper = BollingerBands(price = MACD, length = MACDLength, "average type" = averageType).UpperBand;
plot BBLower = BollingerBands(price = MACD, length = MACDLength, "average type" = averageType).LowerBand;
plot Diff = MACD - BB;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
MACD.SetDefaultColor(GetColor(1));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
ZeroLine.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up") );
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
(pasted screenshot )
February 19th, 2021, 08:25 PM
Weston, Florida, USA
Experience: Advanced
Platform: Ninja Trader
Trading: ES, CL, TF, 6E, GC
Posts: 47 since Oct 2010
Thanks Given: 49
Thanks Received: 49
Hi Jc,
Sorry, I just saw your reply.
Actually, your code needs the standard deviation (as an input) of the Bollinger Bands which by default is 2, but sometimes I use 1.
When the Diff is above the Upper Band then you get a long signal and when is below the lower band then you get the sell signal. If you leave the St.Dev at 2 you get very few signals, if you change it to 1 then you get more signals, so you need to change that in your code also.
If you can modify those 2 lines of code that'll be great!!
Thanks a lot,
Alan
JayC
Never seen MACDBBLines before, so this might be completely wrong. Also, this mostly just copy paste from the built-in versions of MACD and BB. I replaced the average line in MACD with BB lines. If you can provide more specific requirements, I can customize it further if you need.
JaycC
Code
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = yes;
plot MACD = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot BB = BollingerBands(price = MACD, length = MACDLength, "average type" = averageType).MidLine;
plot BBUpper = BollingerBands(price = MACD, length = MACDLength, "average type" = averageType).UpperBand;
plot BBLower = BollingerBands(price = MACD, length = MACDLength, "average type" = averageType).LowerBand;
plot Diff = MACD - BB;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
MACD.SetDefaultColor(GetColor(1));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
ZeroLine.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up") );
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
(pasted screenshot )
February 19th, 2021, 11:48 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
Here's another attempt. I added the standard deviation input and I removed the Diff plot entirely. The MACD is now charted as dots that change to buy/sell signals if they are above/below the BB bands.
Jay
Code
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = yes;
input stdev = 2;
plot MACD = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot BB = BollingerBands(price = MACD, length = MACDLength, "average type" = averageType, "num dev dn" = -stdev, "num dev up" = stdev).MidLine;
plot BBUpper = BollingerBands(price = MACD, length = MACDLength, "average type" = averageType, "num dev dn" = -stdev, "num dev up" = stdev).UpperBand;
plot BBLower = BollingerBands(price = MACD, length = MACDLength, "average type" = averageType, "num dev dn" = -stdev, "num dev up" = stdev).LowerBand;
MACD.SetDefaultColor(GetColor(1));
MACD.AssignValueColor(if MACD > BBUpper then Color.UPTICK else if MACD < BBLower then Color.DOWNTICK else Color.CURRENT);
BB.SetDefaultColor(Color.LIGHT_GRAY);
BBUpper.SetDefaultColor(Color.LIGHT_GRAY);
BBLower.SetDefaultColor(Color.LIGHT_GRAY);
Last Updated on February 19, 2021