Author

Topic: Arnaud Legoux Moving Average (Read 2692 times)

newbie
Activity: 1
Merit: 0
April 28, 2020, 02:49:20 AM
#4
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
full member
Activity: 152
Merit: 100
March 02, 2014, 01:33:16 AM
#3
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.
newbie
Activity: 4
Merit: 0
March 01, 2014, 09:31:01 PM
#2
Can I ask why you use 2 * s * s?
full member
Activity: 152
Merit: 100
February 28, 2014, 08:35:51 PM
#1
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!
Jump to: