Hi grommets,
I have been learning to code with my new toys…MT4 & MQL4. While I was checking out some code today I found out something very interesting…
I have read through some of the threads on this forum and it looks like you guys already know that the ‘built in’ MT4 MACD indicator DOES NOT show the true MACD histogram at all (it plots the actual MACD line as a histogram…instead of a line).
OK…so that is where theOsMA custom indicator comes in. You just open her up and hey presto…there’s the proper Histogram. Right?
WRONG.
I have read through the code and found that the OsMA signal line is created using a simple moving average…when in fact it should be an exponential MA.
I have checked out MACD formulas on quite a few sites, and they all say the same thing…
ALL MOVING AVERAGE CALCULATIONS USED TO CREATE THE TRUE MACD INDICATOR (and subsequently the MACD Histogram) ARE EXPONENTIAL MOVING AVERAGES.
“So what…big deal” I hear you say.
Well, check out the chart I made up and attached.
The top one is the dodgy built in MACD indicator (mostly useless for the cowabunga system).
The middle one is the standard OsMA custom indicator that is part of the MT4 download package (better…but there are still lumps in the porridge).
The bottom one is the OsMA with the code changed so that the MACD signal line used to generate the Histogram is calculated with EMA instead of SMA (oh yeah baby…we like it like that :D).
You can see some fairly big differences - the standard Osma had a zero line crossover at the yellow vertical line, but the EMA corrected version did not cross till 3 bars later at the red vertical line. And earlier in the chart - the circled bars are the ones displayed in the data panel (one shows negative value and the other shows positive). This is quite significant when you are using these indicators to validate your entry signals.
OK…now that I have upset the apple cart, let me try and smooth things over a bit.
Instructions for amending the OsMA indicator:
*Put down your coffee.
*Open up MetaEditor (click the yellow exclamation mark icon at the top of the Meta trader screen).
*In MetaEditor - click ‘File’ then ‘Open…’ Find and select the file OsMA.mq4
*OK, now you have the code in front of you…look down at the bottom right corner of your screen…you will see a line and column reference. move the cusor through the code until you get to Ln57 Col67. Change the code from MODE_SMA to MODE_EMA.
*Save the file (change the name if you want to keep the old OsMA).
*Click where it says ‘Compile’ at the top of the screen.
*Close the editor and go find your new toy in The Metaquotes terminal.
*Send $500 to paypal accou…hehe, just kidding. :rolleyes:
Now you have your very own fair dinkum real McCoy MACD Histogram so get out your candles and wax up those boards dudes…it’s COWABUNGA time!