# Duplicate: ALMA, was: How to use indicator from internet in coding?

I download a indicator formula called ALMA from internet but I can't use it in coding.

If I want to use MA in afl coding, I will type MA(ARRAY, Range); . But that doesn't work with ALMA. How can I put alma indicator in my afl? Here is ALMA.

``````//
function ALMA(priceField, windowSize, sigma, Offset)
{
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))/(s*s)); // 2 should be there?
wSum += w[i];
}

for(i = 1; i < windowSize; i++)
{
w[i] = w[i] / wSum;
}

outalma = Null;

for(j = 0; j < BarCount; j++)
{
alSum = 0;

if(j < windowSize)
{
outalma[j] = Null;
}
else
{
for(i = 1; i < windowSize; i++)
{
alSum += priceField[j - (windowSize - 1 - i)] * w[i];
}

outalma[j] = alSum;
}
}

return outalma;
}

p = ParamField("Price Field");
windowSize = Param("Window Size", 9, 5, 201, 2);
sigma = Param("Sigma", 6, 1, 20);
Offset = Param("Offset", 0.85, 0.05, 1.0, 0.05);

Plot(ALMA(p, windowSize, sigma, Offset),"ALMA", ParamColor("Color",
colorBlue), ParamStyle("Style"));
``````