%dj=dlmread('^DJI_close.txt');
dj=dlmread('dj_remains.txt');

logdj=dj;%log(dj);%
x=1:length(logdj);
if (size(logdj,1)>size(logdj,2))
    logdj=transpose(logdj);
end
trendcoefs=polyfit(x,logdj,1);
k=trendcoefs(1);
b=trendcoefs(2);
trend=x*k+ones(size(x))*b;
figure;
plot(logdj);
hold on;
plot(trend);

remains=logdj-trend;
begfreq=floor(length(dj)/40);
curfreq=begfreq;
for i=1:5
    [rr,times, extrems,remains]=serier2rr(remains,curfreq);
    curfreq=curfreq*2;
end