I've just found out that GFT's dealbook 360 does not have smoothed moving average. instead it has a modified moving average, but it's not the same thing. I studied MT4's code for smoothed moving average, and tried to transplant it to dealbook without success. here is the code I made, could someone please tell me what's wrong with it?
function SMMA;
input s(series), period(number);
result res(series);
vars i(number), tmp(number), l(number), cnt(number), f(number);
begin
f := front(s);
l := f + period - 1;
cnt := back(s);
if l <= cnt then begin
tmp := 0;
for i := f to l do
tmp := tmp + s[i];
res[l] := tmp / period;
for i := l + 1 to cnt do
res[i] := ((res[l]/period)*(period-1) + s[i]) / period;
end;
end.
thanks a lot in advance!
function SMMA;
input s(series), period(number);
result res(series);
vars i(number), tmp(number), l(number), cnt(number), f(number);
begin
f := front(s);
l := f + period - 1;
cnt := back(s);
if l <= cnt then begin
tmp := 0;
for i := f to l do
tmp := tmp + s[i];
res[l] := tmp / period;
for i := l + 1 to cnt do
res[i] := ((res[l]/period)*(period-1) + s[i]) / period;
end;
end.
thanks a lot in advance!