请问amibroker的ema和sma如何实现?!

Discussion in 'AmiBroker' started by wj2000, Oct 31, 2008.

  1. 请问amibroker的ema和sma如何实现?!
    因为想对ema函数做些调整,要知道amibroker里函数ema是如何实现的?哪里有相关资料?
    谢谢
     
  2. 可能可以这样实现这个sma函数,还没核对数据
    function fSMA(x, n,m)
    {
    MAVt[0]=0;
    for(i=1; i<BarCount; i++)
    MAVt = (m*x[i-1] + (n-m)*MAVt[i-1]) / n;
    return MAVt;
    }
     
  3. 借鉴的类似几个函数
    http://www.amibroker.com/guide/afl/afl_view.php?id=18
    output = AMA( input, factor )

    is equivalent to the following looping code:

    for( i = 1; i < BarCount; i++ )
    {
    output[ i ] = factor[ i ] * input[ i ] + ( 1 - factor[ i ] ) * output[ i - 1 ];
    }


    http://www.amibroker.com/guide/afl/afl_view.php?id=42
    DEMA can also be implemented using new for looping:

    Len = 20;
    Plot( DEMA( Close, Len ), "Built-in DEMA", colorRed );

    factor = 2 / (Len + 1 );

    e1 = e2 = Close[ 0 ]; // initialize

    for( i = 0; i < BarCount; i++ )
    {
    e1 = factor * Close[ i ] + ( 1 - factor ) * e1;
    e2 = factor * e1 + ( 1 - factor ) * e2;

    myDema[ i ] = 2 * e1 - e2;
    }

    Plot( myDema, "Dema in loop", colorBlue );