Normal
0
false
false
false
EN-US
X-NONE
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:6.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
Hello!
I just downloaded the Forum's MAMA FAMA .dll file. It works great. Thanks for making it available!
Before I located the .dll, I had been trying to code this beast myself for a couple of days. Now, after all the work I put into this, I would still like to understand why my own MS coding of MAMA did not work. This is just
purely academic interest; and, being new at MS coding, I would just enjoy getting some closure seeing my own code working.
So far I have stepped through each statement of the
code from start to finish, and I have evaluated each term, ratio, arctangent,
phase, period to see that the numerical results are all within reasonable
bounds and do not blow up. However, the
results from the code below leave the MAMA and FAMA as spikes that are nowhere
near the price values.
The only clue I have is that Ehler's Easy Language
initialization of all variables to zero is not commensurate with the Metastock
code. It “works” when I initialize MAMA and
FAMA equal to the typical price, and then *both* FAMA and MAMA stick to the prices to
resemble a very short moving average. However, this certainly does not resemble the MS Forum's dll version, and FAMA never diverges from MAMA.
Here is my code.
What am I doing wrong?
Thanks for your help!
Joe
---------------------------------------------------------------
Price1 := Typical();
FastLimit := 0.5;
SlowLimit := 0.05;
Smooth := 0;
Detrender := 0;
In1 := 0;
Qd1 := 0;
In2 := 0;
Qd2 := 0;
jIn := 0;
jQd :=0;
Re := 0;
Im := 0;
Period := 0;
SmoothPeriod :=0;
Phase := 0;
DeltaPhase := 0;
alpha :=0;
MAMA := 0;
FAMA := 0;
Smooth := (4*Price1 + 3*Ref(Price1,-1) +
2*Ref(Price1,-2)+ Ref(Price1,-3))/10;
Detrender :=
( 0.0962*Smooth + 0.5769*Ref(Smooth,-2) - 0.5769*Ref(Smooth,-4) -
0.0962*Ref(Smooth,-6) ) * (0.075*Ref(Period,-1) + 0.54);
Qd1 := ( 0.0962*Detrender +
0.5769*Ref(Detrender,-2) - 0.5769*Ref(Detrender,-4) - 0.0962*Ref(Detrender,-6)
) * (0.075*Ref(Period,-1) + 0.54);
In1 := Ref(Detrender,-3);
jIn := ( 0.0962*In1 + 0.5769*Ref(In1,-2) -
0.5769*Ref(In1,-4) - 0.0962*Ref(In1,-6) ) * (0.075*Ref(Period,-1) + 0.54);
jQd := ( 0.0962*Qd1 + 0.5769*Ref(Qd1,-2) -
0.5769*Ref(Qd1,-4) - 0.0962*Ref(Qd1,-6) ) * (0.075*Ref(Period,-1) + 0.54);
In2 := In1 -
jQd;
Qd2 := Qd1 +
jIn;
In2 := 0.2 * In2 + 0.8 * Ref(In2, -1);
Qd2 := 0.2 * Qd2 + 0.8 * Ref(Qd2, -1);
Re := In2*Ref(In2,-1) + Qd2*Ref(Qd2,-1);
Im := In2*Ref(Qd2,-1) - Qd2*Ref(In2,-1);
Re := 0.2*Re + 0.8*Ref(Re,-1);
Im := 0.2*Im + 0.8*Ref(Im,-1);
Period
:= If( (Im*Re <> 0),
360/(Atan(Im,Re)), Period);
Period
:= If( Period > 1.5*Ref(Period,-1), 1.5*Ref(Period,-1),
Period);
Period
:= If( Period < 0.67*Ref(Period,-1),
0.67*Ref(Period,-1), Period);
Period :=
If( Period < 6, 6, Period);
Period
:= If( Period > 50, 50,
Period);
Period := 0.2*Period + 0.8*Ref(Period,-1);
{ Not clear why SmoothPeriod was included in Ehler's code, since the calculation does not use it. }
SmoothPeriod := 0.33*Period +
0.67*Ref(Smoothperiod,-1);
Phase := If(In1<>0, Atan(Qd1,In1),Phase);
DeltaPhase := Ref(Phase,-1) - Phase;
DeltaPhase := If(DeltaPhase <1, 1, DeltaPhase);
alpha := FastLimit/Deltaphase;
alpha := If(alpha<SlowLimit,SlowLimit,alpha);
MAMA := alpha*Price1 + (1-alpha)*Ref(MAMA,-1);
FAMA := 0.5*alpha*MAMA +
(1-(0.5*alpha))*Ref(FAMA,-1);
MAMA;
FAMA;
Normal
0
false
false
false
EN-US
X-NONE
X-NONE
MicrosoftInternetExplorer4
ddhbdfdsfh
Joe