Show MACD Histogram only in ThinkorSwim?

T

Trading51

Active member
2019 Donor
Can I get only the MACD histogram to show, have the averages turned off ot an option to turn them off

Code:
#MACD color
declare lower;
input fastLength = 5;
input slowLength = 20;
input MACDLength = 30;

def fastAvg = ExpAverage(data = close, length = fastLength);
def slowAvg = ExpAverage(data = close, length = slowLength);

plot MACD = fastAvg - slowAvg;
MACD.DefineColor( "up",  Color.GREEN );
MACD.DefineColor( "dn",  Color.RED );
MACD.DefineColor( "def", Color.BLACK );
MACD.assignValueColor(if MACD > MACD[1] then MACD.Color( "up" ) else if MACD < MACD[1] then MACD.Color( "dn" ) else MACD.Color( "def" ) );

plot Signal = ExpAverage(data = MACD, length = MACDLength);
Signal.DefineColor( "up",  GetColor(7) );
Signal.DefineColor( "dn",  Color.BLUE );
Signal.DefineColor( "def", Color.BLACK );
Signal.AssignValueColor(if Signal > Signal[1] then Signal.Color( "up" ) else if Signal < Signal[1] then Signal.Color( "dn" ) else Signal.Color( "def" ) );

plot Diff = MACD - Signal;
Diff.HideBubble();
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight( 3 );
Diff.DefineColor("Positive", Color.UPTICK);
Diff.DefineColor("Negative", Color.DOWNTICK);
Diff.AssignValueColor(if diff >= 0 then Diff.color("Positive") else Diff.color("Negative"));

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(0));
ZeroLine.HideBubble();
ZeroLine.HideTitle();

# alert for MACD crossing above zero
Alert( MACD >= 0 and MACD[1] < 0, "MACD above 0", Alert.BAR, Sound.Bell );

# alert for MACD crossing below zero
Alert( MACD < 0 and MACD[1] >= 0, "MACD below 0", Alert.BAR, Sound.Ring );
 
Last edited by a moderator:
BenTen

BenTen

Administrative
Staff
VIP
No need to edit the code. In the indicator's settings page, just uncheck Show plot for MACD and Signal.

 
netarchitech

netarchitech

Well-known member
VIP
@Trading51 If you feel comfortable with editing a little thinkscript and just in case you have more than a couple of charts with MACDs on them, you could save time and enter the following into the code:

MACD.hide();
Signal.hide();

or just copy/paste the code below into your MACD study:

Code:
#MACD color
declare lower;
input fastLength = 5;
input slowLength = 20;
input MACDLength = 30;

def fastAvg = ExpAverage(data = close, length = fastLength);
def slowAvg = ExpAverage(data = close, length = slowLength);

plot MACD = fastAvg - slowAvg;
MACD.DefineColor( "up",  Color.GREEN );
MACD.DefineColor( "dn",  Color.RED );
MACD.DefineColor( "def", Color.BLACK );
MACD.assignValueColor(if MACD > MACD[1] then MACD.Color( "up" ) else if MACD < MACD[1] then MACD.Color( "dn" ) else MACD.Color( "def" ) );

MACD.hide();

plot Signal = ExpAverage(data = MACD, length = MACDLength);
Signal.DefineColor( "up",  GetColor(7) );
Signal.DefineColor( "dn",  Color.BLUE );
Signal.DefineColor( "def", Color.BLACK );
Signal.AssignValueColor(if Signal > Signal[1] then Signal.Color( "up" ) else if Signal < Signal[1] then Signal.Color( "dn" ) else Signal.Color( "def" ) );

Signal.hide();

plot Diff = MACD - Signal;
Diff.HideBubble();
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight( 3 );
Diff.DefineColor("Positive", Color.UPTICK);
Diff.DefineColor("Negative", Color.DOWNTICK);
Diff.AssignValueColor(if diff >= 0 then Diff.color("Positive") else Diff.color("Negative"));

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(0));
ZeroLine.HideBubble();
ZeroLine.HideTitle();

# alert for MACD crossing above zero
Alert( MACD >= 0 and MACD[1] < 0, "MACD above 0", Alert.BAR, Sound.Bell );

# alert for MACD crossing below zero
Alert( MACD < 0 and MACD[1] >= 0, "MACD below 0", Alert.BAR, Sound.Ring );


Hope this helps :)
 
T

Trading51

Active member
2019 Donor
@Trading51 If you feel comfortable with editing a little thinkscript and just in case you have more than a couple of charts with MACDs on them, you could save time and enter the following into the code:

MACD.hide();
Signal.hide();

or just copy/paste the code below into your MACD study:

Code:
#MACD color
declare lower;
input fastLength = 5;
input slowLength = 20;
input MACDLength = 30;

def fastAvg = ExpAverage(data = close, length = fastLength);
def slowAvg = ExpAverage(data = close, length = slowLength);

plot MACD = fastAvg - slowAvg;
MACD.DefineColor( "up",  Color.GREEN );
MACD.DefineColor( "dn",  Color.RED );
MACD.DefineColor( "def", Color.BLACK );
MACD.assignValueColor(if MACD > MACD[1] then MACD.Color( "up" ) else if MACD < MACD[1] then MACD.Color( "dn" ) else MACD.Color( "def" ) );

MACD.hide();

plot Signal = ExpAverage(data = MACD, length = MACDLength);
Signal.DefineColor( "up",  GetColor(7) );
Signal.DefineColor( "dn",  Color.BLUE );
Signal.DefineColor( "def", Color.BLACK );
Signal.AssignValueColor(if Signal > Signal[1] then Signal.Color( "up" ) else if Signal < Signal[1] then Signal.Color( "dn" ) else Signal.Color( "def" ) );

Signal.hide();

plot Diff = MACD - Signal;
Diff.HideBubble();
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight( 3 );
Diff.DefineColor("Positive", Color.UPTICK);
Diff.DefineColor("Negative", Color.DOWNTICK);
Diff.AssignValueColor(if diff >= 0 then Diff.color("Positive") else Diff.color("Negative"));

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(0));
ZeroLine.HideBubble();
ZeroLine.HideTitle();

# alert for MACD crossing above zero
Alert( MACD >= 0 and MACD[1] < 0, "MACD above 0", Alert.BAR, Sound.Bell );

# alert for MACD crossing below zero
Alert( MACD < 0 and MACD[1] >= 0, "MACD below 0", Alert.BAR, Sound.Ring );


Hope this helps :)
that's cool thanks, so when I want to turn something off or hide it I add the indicator.Hide();, is that all is this standard?
MACD.hide();
Signal.hide();
 
horserider

horserider

Well-known member
VIP
Come on everyone. MACDHistogram is an included study in ToS.
 
netarchitech

netarchitech

Well-known member
VIP
...so when I want to turn something off or hide it I add the indicator.Hide(); is that all is this standard?
Yes...and when you want to show something again, put a # in front of the hide statement like this:

#MACD.hide();

Hope this helps :)
 
T

Trading51

Active member
2019 Donor
Yes...and when you want to show something again, put a # in front of the hide statement like this:

#MACD.hide();

Hope this helps :)
Thanks, this one for div is a much better than these others ones
 
horserider

horserider

Well-known member
VIP
Must be in a bad mood but this whole thread is useless. It is standard in ToS. This whole thing should be deleted as clutter.
 
BenTen

BenTen

Administrative
Staff
VIP
@horserider If you're in a bad mood then take it somewhere else. This is a community. You learn new things everyday. Thank you for letting us know that there is a default MACDHistogram indicator in ThinkorSwim but that does not give you the right to make such comment.
 

Similar threads

Top