MACD with Signals

rad14733

Well-known member
VIP
@raymasa Have you searched the forums...??? There are more than a few variations of MACD indicators here in the forums... The same basic layout can be created by combining several standard TOS indicators... We don't generally just do conversions based on one members request, and especially not for a member with only three posts... There needs to be some greater interest... I quickly pieced something quite similar together by stacking several existing indicators in one lower section... What you see below took me less than 2 minutes to accomplish... Very little extra work would be required to make it exactly the same...

Edited to add: It was actually simpler than the original version... Only 2 indicators instead of the original 4...

oby17a7.png


hxwnv8v.png
 
Last edited:

rad14733

Well-known member
VIP
@raymasa Actually, I was bored and curiosity got the best of me so I coded a replica based off the standard TOS MACD indicator... I never checked to see whether a comparable script might already be posted here in the forums... It didn't take long considering how my initial reply was only about 1H 15m ago, and I did a few other things along the way... Just goes to show how easy code can be tweaked with very little effort...

Ruby:
# MACD_with_Signals_and_ColorBars
# Adapted from Tradingview MACD_with_Signals
# https://www.tradingview.com/script/ETBoNc7O-MACD-with-Signals/
# Based on TOS MACD with additional features
# TD Ameritrade IP Company, Inc. (c) 2007-2021
# Created by rad14733 for usethinkscript.com
# v1.0 : 2021-02-25 : Initial release

declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = yes;
input colorChartBars = yes;

plot Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.BLUE);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.YELLOW);
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"));

plot UpSignal = if Diff crosses above 0 then 0 else Double.NaN;
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.SetLineWeight(2);
UpSignal.SetHiding(!showBreakoutSignals);

plot DownSignal = if Diff crosses below 0 then 0 else Double.NaN;
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.SetLineWeight(2);
DownSignal.SetHiding(!showBreakoutSignals);

plot Value = MACD(fastLength, slowLength, MACDLength, averageType).Value;
Value.SetDefaultColor(Color.CYAN);
Value.DefineColor("UpTrend", Color.CYAN);
Value.DefineColor("DownTrend", Color.MAGENTA);
Value.AssignValueColor(if Value > Value[1] then Value.color("UpTrend") else if Value < Value[1] then Value.color("DownTrend") else Color.CURRENT);
Value.SetLineWeight(2);

plot Avg = MACD(fastLength, slowLength, MACDLength, averageType).Avg;
Avg.SetDefaultColor(Color.DARK_ORANGE);
Avg.SetLineWeight(1);

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.WHITE);
ZeroLine.SetLineWeight(1);

AssignPriceColor(if colorChartBars then 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") else Color.CURRENT);

# END - MACD_with_Signals_and_ColorBars

pS18n1I.png
 
Last edited:

raymasa

New member
@raymasa Have you searched the forums...??? There are more than a few variations of MACD indicators here in the forums... The same basic layout can be created by combining several standard TOS indicators... We don't generally just do conversions based on one members request, and especially not for a member with only three posts... There needs to be some greater interest... I quickly pieced something quite similar together by stacking several existing indicators in one lower section... What you see below took me less than 2 minutes to accomplish... Very little extra work would be required to make it exactly the same...

Edited to add: It was actually simpler than the original version... Only 2 indicators instead of the original 4...

oby17a7.png


hxwnv8v.png
I searched, but I missed it, still trying to find my way around this great site...:). Thank you for the studies, I will try these out.
 

raymasa

New member
@raymasa Actually, I was bored and curiosity got the best of me so I coded a replica based off the standard TOS MACD indicator... I never checked to see whether a comparable script might already be posted here in the forums... It didn't take long considering how my initial reply was only about 1H 15m ago, and I did a few other things along the way... Just goes to show how easy code can be tweaked with very little effort...

Ruby:
# MACD_with_Signals_and_ColorBars
# Adapted from Tradingview MACD_with_Signals
# https://www.tradingview.com/script/ETBoNc7O-MACD-with-Signals/
# Based on TOS MACD with additional features
# TD Ameritrade IP Company, Inc. (c) 2007-2021
# Created by rad14733 for usethinkscript.com
# v1.0 : 2021-02-25 : Initial release

declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = yes;
input colorChartBars = yes;

plot Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.BLUE);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.YELLOW);
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"));

plot UpSignal = if Diff crosses above 0 then 0 else Double.NaN;
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.SetLineWeight(2);
UpSignal.SetHiding(!showBreakoutSignals);

plot DownSignal = if Diff crosses below 0 then 0 else Double.NaN;
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.SetLineWeight(2);
DownSignal.SetHiding(!showBreakoutSignals);

plot Value = MACD(fastLength, slowLength, MACDLength, averageType).Value;
Value.SetDefaultColor(Color.CYAN);
Value.DefineColor("UpTrend", Color.CYAN);
Value.DefineColor("DownTrend", Color.MAGENTA);
Value.AssignValueColor(if Value > Value[1] then Value.color("UpTrend") else if Value < Value[1] then Value.color("DownTrend") else Color.CURRENT);
Value.SetLineWeight(2);

plot Avg = MACD(fastLength, slowLength, MACDLength, averageType).Avg;
Avg.SetDefaultColor(Color.DARK_ORANGE);
Avg.SetLineWeight(1);

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.WHITE);
ZeroLine.SetLineWeight(1);

AssignPriceColor(if colorChartBars then 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") else Color.CURRENT);

# END - MACD_with_Signals_and_ColorBars

pS18n1I.png
Thanks for this as well, looks like I have busy weekend playing with these. Thank you.
 

Similar threads

Top