function [xaverage]=xaverage_TS(price,longueur)

if size(price,2)>size(price,1)
    price=price';
end;
xaverage=zeros(size(price,1),1);
xaverage(4)=price(4);
coef=2/(longueur+1);

for i=5:size(price,1)
    xaverage(i)=xaverage(i-1)+coef*(price(i)-xaverage(i-1));
end;
xaverage=round(xaverage*100000)*0.00001;