MAMA from MESA website
Author: karla2010
Creation Date: 9/24/2013 12:32 PM
profile picture

karla2010

#1
I coded Ehlers Easy Language version of MAMA from the MESA website, line by line into C#(WLP).

The result matches very closely to the WLP version but differs around rapid changes. The WLP version has smoother edges in the stair steps that one expects from the discontinuous phase transitions in the arctan function.

Is WLP using the same cutoffs as Ehlers for Period and Phase? Is WLP doing some additional smoothing?

Basically all the stairstep locations match within a sample or two but the WLP version has rounded transitions.

profile picture

Eugene

#2
Sometimes indicator authors revise their creations. Not assuming that this is the case here, but MAMA was coded against the the September 2001 issue of Stocks & Commodities magazine. Are you sure the website reflects that version of MAMA?
profile picture

karla2010

#3
ok I don't have a subscription to S&C but I did go to the website and the Traders Tips for 9/2001. One of the contributors showed their code for MAMA and I went through it line by line and it looks the same as the Ehlers version I have.

So the version I have matches the 2001 edition.

Something nonetheless is different. There are some things I like about the WLP version and some things I like about my version.

I'd like to figure out the difference. Either you can release the WLP version so I can go over it and figure out the difference or I'd be happy to publish my version here and you can go over it and decide what is different. I know you are busy and as I said I'd be happy to do the work.
profile picture

Eugene

#4
Sorry, MAMA is a standard indicator. This implies that its implementation is closed source. If you post your script here, we could run it to compare what kind of difference is there.
profile picture

karla2010

#5
ok, here is my version.

The main difference is that I initialize the MAMA computation to get a smooth run in for the values as opposed to the on/off effect seen in WLP.

Ehlers also uses Easy Language so the Atan function is in degrees. I do a conversion from rads to degrees to be consistent with his cutoff(C# uses rads).

I also use double[7] in place of series since there is no need for the detrend, quad and inphase to be series, since only 7 values are needed at any one time and we just dispose of them at the end of the computation.

The remainder follows MESA's published version. I've documented the code the best I could without getting too wordy. The output is of type double[Bars.Count] which I then load into a series for plotting etc.

CODE:
Please log in to see this code.
profile picture

Eugene

#6
Thanks for sharing your version. Your code looks much longer than Fidelity's implementation in WL6 and Ehlers' EasyLanguage code, too. That's enough to explain the difference.
profile picture

karla2010

#7
hmmmm! My code from the >5 bar is exactly the same as Ehlers, so not sure what you are saying. In any case I'll stick with Ehlers version.
profile picture

Eugene

#8
The Ehlers' version from the PDF above is only 80 lines long. I can estimate Wealth-Lab's version as slightly over 100 lines. Your routine has 230 lines.
profile picture

karla2010

#9
guess we are talking past each other a bit here. If I split a long line, add blank lines, or precompute a piece (e.g. (0.075*period(1) + 0.54) which is used repeatedly, you consider it a complication, I just think of it as efficient and readable code. In any case as I said, for bars > 5, my code is the same as Ehlers core solution. The DSP stuff is exactly the same as Ehlers and I have enough DSP background that I understand what he did, I'm not sure what WLP has done, so I'm just more comfortable with what I can see. I understand the decision to keep certain code proprietary.