6827 18 2121
4 Coloured MACD
lime = positive rising
green = positive descending
red = positive rising
maroon = positive descending
Remove from Favorite Scripts Add to Favorite Scripts
study(shorttitle = "MACD 4C", title = "4 colour MACD")
fastMA = input(title="Fast moving average", type = integer, defval = 12, minval = 7)
slowMA = input(title="Slow moving average", type = integer, defval = 26, minval = 7)
lastColor = yellow
[currMacd,_,_] = macd(close[0], fastMA, slowMA, 9)
[prevMacd,_,_] = macd(close[1], fastMA, slowMA, 9)
plotColor = currMacd > 0 
    ? currMacd > prevMacd ? lime : green 
    : currMacd < prevMacd ? maroon : red
plot(currMacd, style = histogram, color = plotColor, linewidth = 3)
plot(0, title = "Zero line", linewidth = 1, color = gray)
ski4ever PRO
2 years ago
Copied and pasted the script into the script editor.
Save, and Add to Chart - voilà!
Thanks Victor!
+2 Reply
Les.C
2 years ago
Thanks Victor!
Reply
BWilliam
2 years ago
I love using MACD. This usage is the closest direct correlation to price/candle changes.
Reply
vkno422 PRO
2 years ago
To get the script add it to your favorite sripts by clicking the star next to the script. It should then show blue.
Then click on "indicators" above your chart (you need to click on the word rather than the arrow next to it).
You will see a group on the left called "favorites". The MACD 4C should show in there. Just click on it to add it to the chart.
+1 Reply
BWilliam vkno422
2 years ago
Thanks Vic... I finally got it to work.
+1 Reply
MarkLangley PRO vkno422
2 years ago
Thank you Victor
+2 Reply
Money_Snake
a year ago
Thank you Victor, MACD added
Reply
samehanwer1000
a year ago
great
Reply
jacobtrading68
a year ago
Thanks Victor!
Reply
J.Livermore PRO
11 months ago
Why does the MACD differs from standard MACD (try with the one by default) ?

I don't get it by looking the code.
Reply
Kantardziski PRO J.Livermore
8 months ago
I cant tell either.
Reply
Kantardziski PRO Kantardziski
8 months ago
Well actually, it is something to do with the portion of script changing the colors of macd... Take that out and it performs normally.
Reply
Kantardziski PRO Kantardziski
8 months ago
As a prudent person, it is difficult to think nearly 1000 likes and this has slipped by ever user... in other words, its certainly possible I am missing something.
Reply
vkno422 PRO J.Livermore
8 months ago
It's very simple really. In most MACD's the MACD value is shown as a line, here it is the MACD value that is shown as a histogram.
Reply
balong
6 months ago
Thank you very much sir . I got it!!!!
Reply
Dejan78
4 months ago
Tnx.
Reply
JoseNeto PRO
2 months ago
Good Job
Reply
Tim8917 PRO
a month ago
Thanks Victor
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out