I have tried both of this code found from Amibroker. I did not say this explicitly, sorry for that.

```
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"));`
```

and yes '2' should be there,

OR

```
// ALMA (Arnaud Legoux Moving Average)
// ALMA is shifted Gaussian distribution FIR filter,
// more info: http://www.arnaudlegoux.com
// http://en.wikipedia.org/wiki/Arnaud_Legoux_Moving_Average
// AFL code (C)2011 AmiBroker.com
function ALMA_AFL( input, range, offset, sigma )
{
local m, im, s, Coeff;
m = ( Offset * (range - 1) );
s = range / sigma;
for( i = 0; i < Min( range, BarCount ); i++ )
{
im = i - m; // apply shift
Coeff[ i ] = exp( - ( im * im ) / ( 2 * s * s ) ); // Gaussian distribution
}
return FIR( input, Coeff, range );
}
P = ParamField("Price field",-1);
range = Param("range", 9, 5, 201, 2 );
Offset = Param("Offset", 6, 1, 20 );
sigma = Param("Sigma", 0.85, 0.05, 1.0, 0.05 );
dynamic_color = IIf( Ref(ALMA_AFL(p, range, sigma, Offset), 0) > Ref(ALMA_AFL(p, range, sigma, Offset), -1), colorGreen, colorRed );
Plot( ALMA_AFL( P, range, Offset, Sigma ), _DEFAULT_NAME(), dynamic_color, ParamStyle("Style") );
```

A description is "The offset parameter is used to control the weighting function, which in turn affects the responsiveness of the indicator."

Using the Ref() function to shift the array, Ref( ALMA_AFL( p, range, offset, sigma ), 1) gives the same value as Ref( ALMA_AFL( p, range, offset, sigma ), 0). It is my understanding that ALMA produces a next day value because of its formulation.

Neither the REF() or Offset appear to give the next day value. I understand "tomorrow" doesn't exist. I do believe ALMA produces a tomorrow value that also does not exist except as an extrapolated guess.

I have seen ALMA plots that extend past the last tick by an additional tick. In Amibroker the extended plot cannot be seen or accessed using Ref().

My question is how can the last value be accessed?

Thanks