How to create MACD histogram indicator in MS 8.1?

13 0

zambuck

Experienced member
1,608 102
Try this....

MACD Histogram

( Mov( C,12,E ) - Mov( C,26,E ) ) - Mov( (Mov( C,12,E ) - Mov( C,26,E ) ),9,E )

MACD Histogram Weekly

Mov(If(DayOfWeek()=5,C,Peak(1,If(DayOfWeek()=5,C,0),1)),60,E)-
Mov(If(DayOfWeek()=5,C,Peak(1,If(DayOfWeek()=5,C,0),1)),130,E)-
Mov(Mov(If(DayOfWeek()=5,C,Peak(1,If(DayOfWeek()=5,C,0),1)),60,E)-
Mov(If(DayOfWeek()=5,C,Peak(1,If(DayOfWeek()=5,C,0),1)),130,E),45,E)

webmal

Junior member
13 0
Zambuck, I tried it but it looks nothing like the indicator I mentioned. Thanks anyway.

Anyone else can help?

Webmal

zambuck

Experienced member
1,608 102
I use it and can confirm that it is doing exactly same thing as the chart in your link....You can apply colours to your choice and then save the chart as a template or layout for future use....

esiotrot

Active member
157 0
Not as simple as it looks!

Zambuck's code will give a histogram all right but not the fancy colours or the enclosing lines, at least not in V7.02 which I use.

The way i found to do it was to code two histograms - one with values greater than zero and one less than zero. Apply both to the chart in a new inner window. Make them histograms with different colours. Then apply them again to the same window but this time make them solid lines. Put a horizontal line at zero.

You end up with a chart showing prices plus an inner window with 4 MACD plots, which you now save as a Template.

There may be a clever way of doing this but I don't know what it is.

zambuck

Experienced member
1,608 102
I have added histogram twice in inner window...one is solid line and the other is histogram line...and then added a horizontal lines at 0...that serves the purpose...but I see that the user wants a different colour above / below 0 line...I missed that...

Would you mind posting the codes as to how you achieve the colour bit...?

esiotrot

Active member
157 0
Just in the properties box - it's not code.

BTW - I have used the weekly MACD for some time now mainly as a "trend confirmation" as it crosses zero. How do you use it?

zambuck

Experienced member
1,608 102
The way i found to do it was to code two histograms - one with values greater than zero and one less than zero. Apply both to the chart in a new inner window. Make them histograms with different colours. Then apply them again to the same window but this time make them solid lines. Put a horizontal line at zero.

You did say code in your message above....

Just property box will not change the colours as discussed...i.e...all lines above 0 are say green and all lines below 0 are say red...and that goes for histogram as well I think...

While bars and candles has got that facility, I think to achieve that in an indicator one would require a code...can't be done otherwise.....

How would you have an MACD indicator with values above 0 of one colour and other below zero say red in colour..that must need a code??...

Could you please explain more as I am curious....

I have added the weekly MACD in one layout along with daily one..for quick comparision between daily and weekly charts of MACD...

For establishing the trending securities I use CMO and Aroon...along with VHF.

esiotrot

Active member
157 0
Sorry - I'll try to be a bit clearer.

I code one MACD as an IF - such that if it's less than zero it's the value ( Mov( C,12,E ) - Mov( C,26,E ) ) - Mov( ( Mov( C,12,E ) - Mov( C,26,E ) ),9,E ) other wise it's Zero. It looks like the second image.

Then another one also as IF - such that if it's above zero it's value is ( Mov( C,12,E ) - Mov( C,26,E ) ) - Mov( ( Mov( C,12,E ) - Mov( C,26,E ) ),9,E ) other wise it's zero.

I then use the first one in a new window and use the property box to make it a histogram and colour it Red. I then use the second indicator, in the same inner window, make it a histogram and colour it (in my case) Blue.

To get the defining lines I use each of the the indicators again, but this time I make them a solid line and change the colours to Red and Blue respectively.

Finally to hide the Zeroes I add a black horizontal line at Zero.

Attachments

• Hist1only.jpg
80.6 KB · Views: 430
• HistAAL.jpg
111.5 KB · Views: 493
• Hist1code.jpg
33.1 KB · Views: 449

zambuck

Experienced member
1,608 102
Thanks Peter....I see what you have done...and thanks for the code...I will test this out and see...

webmal

Junior member
13 0
It worked. Thanks Peter!

Replies
0
Views
1K
Replies
7
Views
354
Replies
10
Views
1K
Replies
1
Views
392
Replies
37
Views
5K