//KAMA LBPeriods = Param( "LB Periods", 10, 1, 200, 1 );
FSCPeriods = Param( "FSC Periods", 2, 1, 200, 1 ); SSCPeriods = Param( "SSC Periods", 30, 1, 200, 1 ); FastSmoothConst = 2 / ( FSCPeriods + 1 ); SlowSmoothConst = 2 / ( SSCPeriods + 1 ); Direction = abs( Close - Ref( Close, -LBPeriods ) ); Volatility = Sum( abs( Close - Ref( Close, -1 ) ), LBPeriods ); EfficiencyRatio = Direction / Volatility; SC = ( EfficiencyRatio * ( FastSmoothConst - SlowSmoothConst ) + SlowSmoothConst ) ^ 2; KAMA = AMA( Close, SC ); Plot( KAMA, "KAMA", ParamColor( "Color", colorYellow ), styleLine ); // MAMA and FAMA FastLimit = Param( "Fast Limit", 0.5, 0, 10, 0.1 ); SlowLimit = Param( "Slow Limit", 0.05, 0, 1, 0.01 ); Price = ( H + L ) / 2; Smooth = ( 4 * Price + 3 * Ref( Price, -1 ) + 2 * Ref( Price, -2 ) + Ref( Price, -3 ) ) / 10; Detrender = Smooth; II2 = Smooth; Q2 = Smooth; Re = Smooth; Im = Smooth; I1 = Smooth; Q1 = Smooth; jl = Smooth; jQ = Smooth; Phase = Smooth; DeltaPhase = Smooth; Period = Smooth; PI = 3.1415926; for ( i = 0; i < BarCount; i++ ) { if ( i < 6 ) { // init previous values to avoid problems // with exp. averaging of uninitialized values // later DeltaPhase[ i ] = 0; II2[ i ] = 1.0; Q2[ i ] = 1.0; Re[ i ] = 0; Im[ i ] = 0; Period[ i ] = 6; } else { factor = 0.075 * Period[ i - 1 ] + 0.54; Detrender[ i ] = ( ( 0.0962 *Smooth[ i ] + 0.5769 * Smooth[ i-2 ] - 0.5769 * Smooth[ i-4] - 0.0962 * Smooth[ i-6 ] ) * factor ); Q1[ i ] = ( ( 0.0962 *Detrender[ i ] + 0.5769 * Detrender[ i-2 ] - 0.5769 * Detrender[ i-4 ] - 0.0962 * Detrender[ i-6 ] ) * factor ); I1[ i ] = Detrender[ i-3 ]; jl[ i ] = ( ( 0.0962 *I1[ i ] + 0.5769 * I1[ i-2 ] - 0.5769 * I1[ i-4 ] - 0.0962 * I1[ i-6 ] ) * factor ); jQ[ i ] = ( ( 0.0962 *Q1[ i ] + 0.5769 * Q1[ i-2 ] - 0.5769 * Q1[ i-4 ] - 0.0962 * Q1[ i-6 ] ) * factor ); II2[ i ] = I1[ i ] - jQ[ i ]; Q2[ i ] = Q1[ i ] + jl[ i ]; II2[ i ] = 0.2 * II2[ i ] + 0.8 * II2[ i-1 ]; Q2[ i ] = 0.2 * Q2[ i ] + 0.8 * Q2[ i-1 ]; Re[ i ] = II2[ i ] * II2[ i-1 ] + Q2[ i ] * Q2[ i-1 ]; Im[ i ] = II2[ i ] * Q2[ i-1 ] - Q2[ i ] * II2[ i-1 ]; Re[ i ] = 0.2 * Re[ i ] + 0.8 * Re[ i-1 ]; Im[ i ] = 0.2 * Im[ i ] + 0.8 * Im[ i-1 ]; Period[ i ] = Period[ i-1 ]; if ( Im[ i ] != 0 AND Re[ i ] != 0 ) Period[ i ] = ( 2 * PI ) / 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 ]; if ( I1[ i ] != 0 ) Phase[ i ] = ( 180 / PI ) * atan( Q1[ i ] / I1[ i ] ); DeltaPhase[ i ] = Phase[ i-1 ] - Phase[ i ]; if ( DeltaPhase[ i ] < 1 ) DeltaPhase[ i ] = 1; } } DeltaPhase = DeltaPhase; alpha = FastLimit / DeltaPhase; alpha = Min( alpha, FastLimit ); // not more than fast limit alpha = Max( alpha, SlowLimit ); // not less than slow limit MAMA = AMA( Price, alpha ); FAMA = AMA( MAMA, 0.5 * alpha ); Plot( MAMA, "MAMA", ParamColor( "MAMA Color", colorYellow ), styleLine ); Plot( FAMA, "FAMA", ParamColor( "FAMA Color", colorRed ), styleLine ); ----- Original Message ----- From: "ihumbleone" <[EMAIL PROTECTED]> To: <amibroker@yahoogroups.com> Sent: Saturday, September 27, 2008 5:31 AM Subject: [amibroker] Kind Request of Ehlers MAMA, FAMA & Kaufman KAMA Indicators with buy sell signal > 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 > > > >