PureBytes Links
Trading Reference Links
|
Dear Tom,
A ready-to-use formula for Mesa moving averages will be available
soon from AmiBroker members area.
Best regards,
Tomasz Janeczko
===============
AmiBroker - the comprehensive share manager.
http://www.amibroker.com
----- Original Message -----
From: "Tom McDaniel" <tmtempe@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, August 28, 2001 2:54 AM
Subject: [amibroker] Any Trade Station Coders Out There?
> Hi all-
>
> I have attempted to code John Ehlers' Mesa Adaptive Moving Averages
> (MAMA) from the TradeStation code presented in the September 2001 issue
> of Technical Analysis of Stocks and Commodities. The code is presented
> below. The results appear to be off by perhaps a scaling factor (or
> something(?!).
>
> I also do not claim to be proficient with AFL so there could be some
> glaring errors there.
>
> Any help or suggestions would be appreciated.
>
> Regards,
> -Tom McDaniel
>
> /* MESA Adaptive Moving Averages (MAMA) */
> /* and Following Adaptive Moving Average (FAMA) */
> /* From John Ehlers' article in Sept. 2001 issue of */
> /* Technical Analysis of Stocks and Commodities */
> /* AFL code by T. L. McDaniel, August, 2001 */
>
> FastLimit = 0.5;
> SlowLimit = 0.05;
> Value = ((H+L)/2);
> Period = 0;
> SmoothPeriod = 0;
> Phase = 0;
> MAMA = 0;
> FAMA = 0;
>
> /* Plot OHLC */
> Graph0Style = 128;
> Graph0 = Close;
>
> /* CurrentBar ? */
> Smooth = (4*Value+3*(Ref(Value,-1))+2*(Ref(Value,-2))+Ref(Value,-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);
>
> /* Compute InPhase and Quadriture Components */
> Q1 = (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));
> I1 = Ref(Detrender,-3);
>
> /* Advance the Phase of I1 and Q1 by 90 degrees */
> J1 = (0.0962*I1 + 0.5769*(Ref(I1,-2)) - 0.5769*(Ref(I1,-4)) -
> 0.0962*(Ref(I1,-6)))*(0.075*(Ref(Period,-1)) + 0.54);
> JQ = (0.0962*Q1 + 0.5769*(Ref(Q1,-2)) - 0.5769*(Ref(Q1,-4)) -
> 0.0962*(Ref(Q1,-6)))*(0.075*(Ref(Period,-1)) + 0.54);
>
> /* Phasor addition for three bar averaging */
> I2 = I1 - JQ;
> Q2 = Q1 + J1;
>
> /* Smooth the I and Q components before applying the discriminator */
> I2 = 0.2*I2 + 0.8*(Ref(I2,-1));
> Q2 = 0.2*Q2 + 0.8*(Ref(Q2,-1));
>
> /* Homodyne Discriminator */
> Re = I2*(Ref(I2,-1)) + Q2*(Ref(Q2,-1));
> Im = I2*(Ref(Q2,-1)) - Q2*(Ref(I2,-1));
> Re = 0.2*Re + 0.8*(Ref(Re,-1));
> Im = 0.2*Im +0.8*(Ref(Im,-1));
> Period = Iif((((Im > 0) or (Im < 0) )and ((Re < 0) or (Re > 0))),
> 360/Atan(Im/Re),0);
> Period = Iif(Period > 1.5*(Ref(Period,-1)), 1.5*(Ref(Period,-1)),
> Period);
> Period = Iif(Period < 0.67*(Ref(Period,-1)), 0.67*(Ref(Period,-1)),
> Period);
> Period = Iif(Period < 6, 6, Period);
> Period = Iif(Period > 50, 50, Period);
> Period = 0.2*Period + 0.8*(Ref(Period,-1));
> SmoothPeriod = 0.33*Period + 0.67*(Ref(SmoothPeriod,-1));
>
> Phase = Iif(I1 < 0 or I1 > 0, Atan(Q1/I1), Phase);
> DeltaPhase = Ref(Phase, -1) - Phase;
> DeltaPhase = Iif(DeltaPhase < 1, 1, DeltaPhase);
> alpha = FastLimit/DeltaPhase;
> alpha = Iif(alpha < SlowLimit, SlowLimit, alpha);
> alpha = Iif(alpha > FastLimit, FastLimit, alpha);
> MAMA = alpha * Value + (1 - alpha)*(Ref(MAMA,-1));
> FAMA = 0.5 * alpha * MAMA + (1- 0.5 * alpha)*(Ref(FAMA,-1));
>
> /* Plot MAMA */
> Graph1Style = 1;
> Graph1 = MAMA;
> Graph2Style = 1;
> Graph2 = FAMA;
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
|