function today_result = drawMACD(hist_dates, hist_close)
today_result = 0;
dates = hist_dates;

%[macd,signal,macdh]  = indicators(cl              ,'macd'   ,short,long,signal)
vout = indicators(hist_close, 'macd', 12,26,9)

     macd = vout(:,1);
     signal = vout(:,2);
     macdh = vout(:,3);
     
macd_out = fints(dates, macd);
signal_out = fints(dates, signal);
macdh_out = fints(dates, macdh);
%close_out = fints(dates, hist_close)

%p1 = plot(close_out, 'r');
%set(p1,'LineWidth',2)
%hold on
%just draw MACD Histogram.
p2 = plot(macd_out,'r')

hold on
set(p2,'LineWidth', 2)
p3 = plot(signal_out,':g')
set(p3,'LineWidth', 2)
 
title('MACD Histogram');
b = bar(macdh_out)
%legend('Close', 'Rychla krivka MACD','Signalni krivka MACD')
legend('Rychla krivka MACD','Signalni krivka MACD')

ylabel({'MACD Histogram'})
xlabel({'Timeline'})


NumTicks = 18;
L = get(gca,'XLim');

set(gca,'XTick',linspace(L(1),L(2),NumTicks))
% set(get(gca,'XLabel'),'Rotation',270)
dateaxis('x', 2)

%----TRITYDENNI
%fileID = fopen('macd_hist3.txt','wt');
flag = 'calm'

for i = 3:length(macd)    
    last_value = macd(i)
    pre_last_value = macd(i - 1)
    pre_pre_last_value = macd(i - 2)
    today = dates{i}
    
    %klesajici trend, tri po sobe jdouci hodnoty klesaji
    if (pre_pre_last_value > pre_last_value && pre_last_value > last_value)
        if(macd(i) > 0)
            flag = '!!! decreasing trend !!!'
        else flag = 'decreasing trend' 
        end
    %rotouci trend, tri po sobe jdouci hodnoty stoupaji
    elseif(pre_pre_last_value < pre_last_value && pre_last_value < last_value)
       if(macd(i) < 0)
            flag = '!!! increasing trend !!!'
       else flag = 'increasing trend'
       end
    else flag = 'calm'
    end
 
% nbytes = fprintf(fileID,'day : %s, pre_last_value : %f, last_value : %f, flag - %s\n', today, pre_last_value, last_value, flag)
end
%fclose(fileID);


%----TRITYDENNI SHODA S CLOSE SMEREM
%fileID = fopen('macd_hist3CLOSE.txt','wt');
flag = 'calm'

for i = 3:length(macd)    
    last_value = macd(i)
    pre_last_value = macd(i - 1)
    pre_pre_last_value = macd(i - 2)
    
    last_close = hist_close(i)
    pre_last_close = hist_close(i - 1)
    pre_pre_last_close = hist_close(i - 2)
    
    today = dates{i}
    
    %klesajici trend, tri po sobe jdouci hodnoty klesaji
    if (pre_pre_last_value > pre_last_value && pre_last_value > last_value && pre_pre_last_close > pre_last_close && pre_last_close > last_close)
        if(macd(i) > 0)
            flag = '!!! decreasing trend !!!'
        else flag = 'decreasing trend' 
        end    
    %rotouci trend, tri po sobe jdouci hodnoty stoupaji
    elseif(pre_pre_last_value < pre_last_value && pre_last_value < last_value && pre_pre_last_close < pre_last_close && pre_last_close < last_close)
        if(macd(i) < 0)
            flag = '!!! increasing trend !!!'
        else flag = 'increasing trend'
        end
    else flag = 'calm'
    end
 
 %nbytes = fprintf(fileID,'day : %s, pre_last_value : %f, last_value : %f, flag - %s\n', today, pre_last_value, last_value, flag)
end
%fclose(fileID);



%----DVOUTYDENNI
%fileID = fopen('macd_hist2.txt','wt');
filename = 'MACDhistdata.xlsx';
flag = 'calm'

for i = 2:length(macd)    
    last_value = macd(i)
    pre_last_value = macd(i - 1)
    today = dates{i}
    
    %klesajici trend, tri po sobe jdouci hodnoty klesaji
    if (pre_last_value > last_value)
        if(macd(i) > 0)
            flag = '!!! decreasing trend !!!'
        else flag = 'decreasing trend' 
        end
    %rotouci trend, tri po sobe jdouci hodnoty stoupaji
    elseif(pre_last_value < last_value)
       if(macd(i) < 0)
            flag = '!!! increasing trend !!!'
        else flag = 'increasing trend'
        end
    else flag = 'calm'
    end
 
    A = {'day', today, 'pre_last_value' , pre_last_value, 'last_value', last_value, 'flag', flag}
    sheet = 1;
    xlswrite(filename,A,sheet,strcat('A',num2str(i)));
    
 %nbytes = fprintf(fileID,'day : %s, pre_last_value : %f, last_value : %f, flag - %s\n', today, pre_last_value, last_value, flag)
end
%fclose(fileID);


%----DVOUTYDENNI SHODA S CLOSE
%fileID = fopen('macd_hist2CLOSE.txt','wt');
flag = 'calm'

for i = 2:length(macd)    
    last_value = macd(i)
    pre_last_value = macd(i - 1)
    
    last_close = hist_close(i)
    pre_last_close = hist_close(i - 1)
    today = dates{i}
    
    %klesajici trend, dve po sobe jdouci hodnoty klesaji
    if (pre_last_value > last_value && pre_last_close > last_close)
        if(macd(i) > 0)
            flag = '!!! decreasing trend !!!'
        else flag = 'decreasing trend' 
        end
    %rotouci trend, dve po sobe jdouci hodnoty stoupaji
    elseif(pre_last_value < last_value && pre_last_close < last_close)
       if(macd(i) < 0)
            flag = '!!! increasing trend !!!'
        else flag = 'increasing trend'
        end
    else flag = 'calm'
    end
    
 %nbytes = fprintf(fileID,'day : %s, pre_last_value : %f, last_value : %f, flag - %s\n', today, pre_last_value, last_value, flag)
end
%fclose(fileID);












