_SECTION_BEGIN("KAMA - Kaufman Adaptive Moving Average");
LBPeriods = Param( "LB Periods", 81, 1, 200, 1 );
FSCPeriods = Param( "FSC Periods", 15, 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", colorRed ), styleLine );
_SECTION_END();
"Arnaud Legoux Moving Average";
/*________________________________________________________________________________________________
AFL code by hiscores. Originally posted here http://finance.groups.yahoo.com/grou...message/154257
Minor mod by rmike to Modify the AFL in conformance with NinjaTrader & Metatrader
releases by the original developer.
Release Date - 09 Nov 10
AFL Usage - Moving Average. Further information Can be found at http://www.arnaudlegoux.com/
________________________________________________________________________________________________*/
_SECTION_BEGIN("ALMA");
p = ParamField("Price Field");
windowSize = Param("Window Size", 111, 5, 201, 2);
sigma = Param("Sigma", 1, 1, 20);
Offset = Param("Offset", 0.85, 0.05, 1.0, 0.05);
m = floor(Offset * (windowSize - 1));
s = windowSize / sigma;
w = 0;
wSum = 0;
for(i = 1; i < windowSize; i++)
{
w[i] = exp(-((i-m)*(i-m))/(2*s*s));
wSum += w[i];
}
for(i = 1; i < windowSize; i++)
{
w[i] = w[i] / wSum;
}
alma = Null;
for(j = 1; j < BarCount; j++)
{
alSum = 0;
if(j < windowSize)
{
alma[j] = Null;
}
else
{
for(i = 1; i < windowSize; i++)
{
alSum += p[j - (windowSize - 1 - i)] * w[i];
}
alma[j] = alSum;
}
}
Plot(alma, "ALMA("+windowSize+","+sigma+","+Offset+")", ParamColor("ALMA Color", colorBrightGreen), ParamStyle("ALMA Style", styleLine|styleThick|styleNoLabel), maskDefault);
_SECTION_END();
Comments
Post a Comment