NexusFi: Find Your Edge


Home Menu

 





Need MACDBBLines for ThinkorSwim


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,591 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 2 attachments




 
Search this Thread

Need MACDBBLines for ThinkorSwim

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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #2 (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

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)

Reply With Quote
Thanked by:
  #3 (permalink)
 futuros 
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 View Post
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)


Started this thread Reply With Quote
  #4 (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

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);

Reply With Quote




Last Updated on February 19, 2021


© 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