function [entree,entree_comp,sortie]=RN_target_ochl_daily(date,time,open,close,high,low,nb,e_type,s_type,normalisation,date_debut)

% on utilise les données quotidiennes. 
% nb => délai sur les données d'entrées 
% e_type => type d'entrée : 
%         e_type=1 on prend ochl 
%         e_type=2 on prend c
% s_type => type de sortie : 
%         s_type=1 on prend la taille de la barre positive si haussier, négative si baissière 
%         s_type=2 on prend le sens 1 pour haussier et 0 pour baissier
%         s_type=3 on prend le sens 1 pour haussier et -1 pour baissier
%         s_type=4 on prend c
% normalisation=1 pour normaliser toutes les données entre 0 et 1
% normalisation=2 pour normaliser toutes les données entre -1 et 1, rien si
% ~=1 et 2
% date_debut => date du début des vecteurs données au format jjmmaaaa


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Définition du vecteur entree
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if e_type==1 
    entree_init=zeros(4*nb,size(close-1,1)-nb);
    for i=nb:size(int_close,1)-1
        for j=1:nb
            entree_init(4*(j-1)+1,i-nb+1)=open(i-j+1);
            entree_init(4*(j-1)+2,i-nb+1)=close(i-j+1);
            entree_init(4*(j-1)+3,i-nb+1)=high(i-j+1);
            entree_init(4*(j-1)+4,i-nb+1)=low(i-j+1);
        end;
    end;
end;

if e_type==2 
    entree_init=zeros(1*nb,size(close-1,1)-nb);
    for i=nb:size(close,1)-1
        for j=1:nb
            entree_init(j,i-nb+1)=close(i-j+1);
        end;
    end;
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Définition du vecteur entree_comp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% rsi_1=rsindex(close,5);
% rsi_2=rsindex(close,9);
% rsi_3=rsindex(close,14);
% 
% [fastK_1, fastD_1]= fpctkd(high,low,close, 9, 3, 'e');
% [slowK_1, slowD_1] = spctkd(fastK_1, fastD_1, 3, 'e');
% [fastK_2, fastD_2]= fpctkd(high,low,close, 14, 3, 'e');
% [slowK_2, slowD_2] = spctkd(fastK_2, fastD_2, 3, 'e');
% 
% [macd,moy,diff]=MACD(close,12,26,9);
% 
% cci_1=CCI(close,high,low,14);
% cci_2=CCI(close,high,low,20);
% 
% range=Range(high,low);
% mean_range=tsmovavg(range, 's', 10, 1);
% 
% body=Body(open,close);
% mean_body=tsmovavg(body, 's', 10, 1);
% 
% [ombre_h,ombre_b]=Ombres(open,close,high,low);

mean_1=tsmovavg(close, 's', 5, 1);
mean_2=tsmovavg(close, 's', 10, 1);
mean_3=tsmovavg(close, 's', 20, 1);
mean_4=tsmovavg(close, 's', 60, 1);
mean_5=tsmovavg(close, 's', 120, 1);

% typical_price=typprice(high,low,close);

% entree_comp_int=[rsi_1 rsi_2 fastK_1 fastD_1...
%     cci_1 cci_2 mean_1 mean_2 macd];

% entree_comp_int=[range body mean_range mean_body...
%     typical_price];

entree_comp_int=[mean_1 mean_2 mean_3 mean_4 mean_5];

for num=1:size(entree_comp_int,1)
    if nnz(isnan(entree_comp_int(num,:)))==0
        break;
    end;
end;
nb2=max(nb,num);

[lig,~]=find(date==date_debut);
if lig<nb2
    errordlg('Il n''a pas assez de données avant la date choisie pour couvrir les retards des indicateurs. La date du début du vecteur a été modifiée','date trop veille');
else
    nb2=lig;
end;

entree_comp=entree_comp_int(nb2:end-1,:)';
entree=entree_init(:,nb2-nb+1:end);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Définition du vecteur sortie
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if s_type==1
    sortie=(open(nb2+1:end)-close(nb2+1:end))';
end;

if s_type==2
    for i=nb2+1:size(close,1)
        if (open(i)-close(i))>0 
            sortie(i-nb2)=1;
        end;
        if (open(i)-close(i))<0 
            sortie(i-nb2)=0;
        end;
    end;
end;

if s_type==3
    for i=nb2+1:size(close,1)
        if (open(i)-close(i))>0 
            sortie(i-nb2)=1;
        end;
        if (open(i)-close(i))<0 
            sortie(i-nb2)=-1;
        end;
    end;
end;

if s_type==4
    sortie=close(nb2+1:end)';
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Normalisation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if normalisation==1
    for i=1:size(entree,1)
        entree(i,:)=(entree(i,:)-min(entree(i,:)))/(max(entree(i,:))-min(entree(i,:)));
    end;
    for i=1:size(entree_comp,1)
        entree_comp(i,:)=(entree_comp(i,:)-min(entree_comp(i,:)))/(max(entree_comp(i,:))-min(entree_comp(i,:)));
    end;
    sortie=(sortie-min(sortie))/(max(sortie)-min(sortie));
end;

if normalisation==2
    for i=1:size(entree,1)
        entree(i,:)=(2*entree(i,:)-(max(entree(i,:))+min(entree(i,:))))/(max(entree(i,:))-min(entree(i,:)));
    end;
    for i=1:size(entree_comp,1)
        entree_comp(i,:)=(2*entree_comp(i,:)-(max(entree_comp(i,:))+min(entree_comp(i,:))))/(max(entree_comp(i,:))-min(entree_comp(i,:)));
    end;
    sortie=(2*sortie-(max(sortie)+min(sortie)))/(max(sortie)-min(sortie));
end;

