yes I looked at the formula they give and written it in another form but gives same result:
_SECTION_BEGIN( "ELMA" );
//Exponential Logarithmic Moving Average
function ELMA( src, len, lambda )
{
res = Null;
for( i = len; i < BarCount; i++ )
{
weightedLogSum = 0.0;
totalWeight = 0.0;
for( j = 0; j < len; j++ )
{
weight = exp( -lambda * j );
logValue = log( src[i - j] );
weightedLogSum = weightedLogSum + ( logValue * weight );
totalWeight = totalWeight + weight;
}
res[i] = exp( weightedLogSum / totalWeight );
}
return res;
}
function ELMA2( src, len, lambda )
{
res = Null;
for( i = len; i < BarCount; i++ )
{
numerator = 0;
denominator = 0;
for( j = 0; j < len; j++ )
{
numerator = numerator + exp( -lambda * j ) * log( src[i - j] );
denominator = denominator + exp( -lambda * j );
}
res[i] = exp( SafeDivide( numerator, denominator ) );
}
return res;
}
function MA2( src, len )
{
res = Null;
for( i = len; i < BarCount; i++ )
{
for( j = 0; j < len; j++ )
{
res[i] = Nz( res[i] ) + src[i - j];
}
res[i] = res[i] / len;
}
return res;
}
length = Param( "length", 20, 2, 100, 1 );
lambda = Param( "Decay Rate", 0.0618, 0.0118, 0.0918, 0.01 );
ELMAValue = ELMA( C, length, lambda );
ELMAValue2 = ELMA2( C, length, lambda );
SetChartBkColor( ColorRGB( 0, 0, 0 ) );
SetChartOptions( 0, chartShowArrows | chartShowDates );
Plot( C, "C", colorWhite, styleCandle, Null, Null, 0, 0, 0 );
Plot( ELMAValue, "ELMA", ColorGreen, StyleThick );
Plot( ELMAValue2, "ELMA2", colorOrange, StyleThick );
Plot( EMA( C, length ), "EMA", colorGold, styleLine, Null, Null, 0, 0, 1 );
//Plot( MA( C, length ), "MA", colorRed, styleLine, Null, Null, 0, 0, 1 );
//Plot( MA2( C, length ), "MA2", colorBlue, styleLine, Null, Null, 0, 0, 1 );
_SECTION_END();