Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 21:55:34 +0000



Post From: Arnaud Legoux Moving Average

[2020-08-20 03:44:54]
SC Support Tom - Posts: 450
The references in Post #14 use the same formulas as the references that I gave in Posts #3 and #11.


Research on quantitative forecasting in food prices:

https://www.cjournal.cz/files/308.pdf

The formula cited in that paper is in the attached image. It is the same as post #3.

Yes, this is the formula that looks like it is missing a factor of 2 in the denominator of the exponent. That is, I would expect to see 2*sigma^2 in the denominator of the exponent if this is a Gaussian filter. The absence of the 2 means that the weights are squares of Gaussian weights.


Below is a version written for Tradestation in 2010, shortly after the ALMA was introduced. No evidence of its accuracy but was written by a very respected coder on ForexFactory.


{Function; ALAverage}

inputs:

Price (numericseries),

Window(numericsimple),

Sigma(numericsimple),

Offset(numericsimple);



variables: m(0),s(0),Wtd(0), WtdSum(0),CumWt(0), k(0);



m = Floor(Offset * (Window - 1));

s = Window/Sigma;



WtdSum = 0;

CumWt = 0;



for k = 0 to Window - 1 begin

Wtd = ExpValue(-((k-m)*(k-m))/(2*s*s));

WtdSum = WtdSum + Wtd * Price[Window - 1 - k] ;

CumWt = CumWt + Wtd;

end ;



ALAverage = WtdSum / CumWt ;

This uses the same formula as the code in the link that I provided in Post #13, and it has even bigger problems than just a missing 2. In this formula, the width of the distribution increases as sigma decreases, and the width decreases as sigma increases. That is the exact opposite of what is supposed to happen. This formula would make more sense if s = Window/Sigma were replaced with s = Sigma/Window.

Unfortunately, I am no closer to being able to implement this study.