[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Kind Request of Ehlers MAMA, FAMA & Kaufman KAMA Indicators with buy sell signal



PureBytes Links

Trading Reference Links

On 2nd thoughts, scrub round that...there's a script in the members 
zone that works just fine...

--- In amibroker@xxxxxxxxxxxxxxx, "ian_rosbif" <ian_rosbif@xxx> wrote:
>
> Hi,
> I copied & translated this from 
> <https://www.sierrachart.com/supportboard/archive/index.php/t-
> 17446.html>. It's not quite right though. It looks OK till you 
click 
> on the chart or scroll it, then it seems to re-calculate & plot a 
> plateau. I'd appreciate someone else's input, as it looks as if it 
> could prove quite useful.
> Cheers,
> Ian
> 
> Price = Close;
> SmoothPeriod = Smooth = Detrender = Q1 = I1 = j1 = jQ = I2 = Q2 = 
Re 
> = Im = Period = SmoothPeriod = Phase = 0;
> FastLimit = 0.5;
> SlowLimit = 0.05;
> MAMA = 0;
> FAMA = 0;
> 
> // smooth
> Smooth = (4*Price + 3*Ref(Price,-1) + 2*Ref(Price,-2) + Ref(Price,-
> 3))/10; 
> 
> for (i = 6; i < BarCount -1; i++)
> {
> // detrender
> Detrender[i] = (0.0962*Smooth[i] + 0.5769*Smooth[i-2] - 
0.5769*Smooth
> [i-4] - 0.0962*Smooth[i-6])*(0.075*Period[i-1] + 0.54); 
> 
> // compute InPhase and Quadrature components
> Q1[i] = (0.0962*Detrender[i] + 0.5769*Detrender[i-2] - 
> 0.5769*Detrender[i-4] - 0.0962*Detrender[i-6])*(0.075*Period[i-1] + 
> 0.54); 
> I1[i] = Detrender[i-3];
> 
> // Advance the phase of I1 and Q1 by 90 degrees
> jI[i] = (0.0962*I1[i] + 0.5769*I1[i-2] - 0.5769*I1[i-4] - 0.0962*I1
[i-
> 6])*(0.075*Period[i-1] + 0.54); 
> jQ[i] = (0.0962*Q1[i] + 0.5769*Q1[i-2] - 0.5769*Q1[i-4] - 0.0962*Q1
[i-
> 6])*(0.075*Period[i-1] + 0.54);
> 
> // Phasor addition for 3 bar averaging
> I2[i] = I1[i] - jQ[i]; 
> Q2[i] = Q1[i] + jI[i];
> 
> // Smooth the I and Q components before applying the discriminator
> I2[i] = 0.2*I2[i] + 0.8*I2[i-1]; 
> Q2[i] = 0.2*Q2[i] + 0.8*Q2[i-1];
> 
> // Homodyne Discriminator
> Re[i] = I2[i]*I2[i-1] + Q2[i]*Q2[i-1]; 
> Im[i] = I2[i]*Q2[i-1] - Q2[i]*I2[i-1]; 
> Re[i] = 0.2*Re[i] + 0.8*Re[i-1]; 
> Im[i] = 0.2*Im[i] + 0.8*Im[i-1]; 
> 
> if (Im[i] != 0.0 AND Re[i] != 0.0)
> {
>  Period[i] = 360/(57.3*atan(Im[i]/Re[i]));
> }
> if (Period[i] > 1.5*Period[i-1])
> {
>  Period[i] = 1.5*Period[i-1];
> }
> if (Period[i] < 0.67*Period[i-1])
> {
>  Period[i] = 0.67*Period[i-1];
> }
> if (Period[i] < 6)
> {
>  Period[i] = 6;
> }
> if (Period[i] > 50)
> {
>  Period[i] = 50;
> }
> Period[i] = 0.2*Period[i] + 0.8*Period[i-1];
> SmoothPeriod[i] = 0.33*Period[i] + 0.67*SmoothPeriod[i-1];
> 
> if (I1[i] != 0) 
> {
>  Phase[i] = 57.3*atan(Q1[i]/I1[i]); 
> }
> DeltaPhase = Phase[i-1] - Phase[i];
> 
> if (IsNull(DeltaPhase) OR DeltaPhase < 1)
> {
>  DeltaPhase = 1;
> }
> alpha = FastLimit / DeltaPhase ;
> if (IsNull(alpha) OR alpha < SlowLimit)
> {
>  alpha = SlowLimit;
> }
> 
> MAMA[i] = alpha*Price[i] + (1 - alpha)*MAMA[i-1];
> FAMA[i] = 0.5*alpha*MAMA[i] + (1 - 0.5*alpha)*FAMA[i-1];
> }
> 
> Plot(MAMA, "MAMA", colorBrightGreen, styleLine+styleThick);
> Plot(FAMA, "FAMA", colorBlue, styleLine+styleThick);
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "ihumbleone" <ihumbleone@> wrote:
> >
> > Hi all,
> > Im a newbie to AFL programming.
> > 
> > May you anyone kindly assist me i have been searching  Amibroker 
> AFL 
> > Formula for for Ehlers MESA Adaptive Moving Average (MAMA and 
FAMA) 
> > with buy sell signals and  Kaufman's Adaptive Moving Average KAMA 
> but 
> > in vain.
> > 
> > It would be great if you can share the formulas if you have them. 
> > 
> > 
> > "The MESA Adaptive Moving Average (MAMA) adapts to price movement 
> > based on the rate of change of phase as measured by the Hilbert 
> > Transform Discriminator (Technical Analysis of Stocks and 
> Commodities 
> > magazine, December 2000). This method features a fast attack 
> average 
> > and a slow decay average so that composite average rapidly 
ratchets 
> > behind price changes and holds the average value until the next 
> > ratchet occurs."  The crossing of the MAMA and FAMA lines can be 
> used 
> > to generate Buy and Sell signals. When the MAMA crosses above the 
> > FAMA a buy signal is given. Alternatively, when the MAMA crosses 
> > below the FAMA a sell signal is given. 
> > 
> > As for KAMA, Developed by Perry Kaufman, this indicator is a 
moving 
> > average that automatically adjusts its speed based on market 
> > volatility.
> > 
> > Sincere Thanks
> > Warmest Rgds
> > Ihumbleone
> >
>



------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/