Bitcoin Forum

Economy => Trading Discussion => Topic started by: Najska on March 01, 2014, 01:35:51 AM



Title: Arnaud Legoux Moving Average
Post by: Najska on March 01, 2014, 01:35:51 AM
Hi fellows,

Let me introduce you ALMA, the best moving average I've ever utilised. This is the website of Arnaud Legoux, where you can find related explanations: http://www.arnaudlegoux.com.

And this is the simple PHP implementation of it:

Code:
function ALMA ($data) {
$sigma = 6;
$offset = 0.85;
$size = count ($data);
$m = $offset * ($size - 1);
$s = $size / $sigma;
$sum = 0;
$norm = 0;
for ($i = 0; $i < $size; $i++) {
$coeff = exp (- ($i - $m) * ($i - $m) / 2 * $s * $s);
$sum += $data[$size - $i - 1] * $coeff;
$norm += $coeff;
}
return $sum / $norm;
}

The array $data will compromise the last closing values, data[0] being the most recent one. It is argued that an odd value for the size of the array would yield better results.

Any opinion is welcome!


Title: Re: Arnaud Legoux Moving Average
Post by: knbitcoin on March 02, 2014, 02:31:01 AM
Can I ask why you use 2 * s * s?


Title: Re: Arnaud Legoux Moving Average
Post by: Najska on March 02, 2014, 06:33:16 AM
Hi knbitcoin,

Thanks for your interest. If you check their website, there is an article describing ALMA, and there are sample codes calculating it. In the article, there is no 2, and there are some other differences as well. But in the code they write, which I only translate to PHP, there is this 2, which in fact improves the result. But I don't know why it is there.


Title: Re: Arnaud Legoux Moving Average
Post by: JackTheBlack on April 28, 2020, 07:49:20 AM
I can confirm that the 2 should be in the code. In codes without 2 other parts are different, too. So, it is result of other calculation if there is 2 or not.
Tradestation code (open source) for ALMA and many other filters (like very good Ehlers SuperSmoother or advanced Kalman) you can find on www.advantagetrading.net/adv-filters.html