function F=rob_TRBB(x,H,tax,time_lag,n)
% -----------------------------------------------------------------
% Elaborated by : BEN HASSEN Anis
% "Institut Suprieur de Gestion de Tunis" (ISG Tunis)
% University of Tunis
% 41, rue de la Libert - Cit Bouchoucha - C.P. : 2000 Le Bardo
% Tunisia
% University e-mail: http://www.isg.rnu.tn/
% Personal e-mail: benhassenanis@yahoo.com
% _________________________________________________________________
% January 14, 2004.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Output:
% F: a 12 element vector by order :
% 1: number of trading days
% 2: number of buy signals
% 3: number of sell signals
% 4: average return on buy signals
% 5: average return on sell signals
% 6: average buy-sell excess return (spread) relative to a buy-and-hold
% strategy and net of transaction costs
% 7: t-statistic of the difference between buys & buy-and-hold returns
% 8: t-statistic of the difference between sells & buy-and-hold returns
% 9: t-statistic of the difference between buy-sell & buy-and-hold returns
% 10,11,12: p-values under the null Hypothesis that the differences are null.
%******************************************************************
% Input:
% x: a column vector of time series (prices Pt)
% H: canal length
% tax: transaction cost on each transaction (in percentage)
% time_lag: introduced if a delay between decision and action is present.
% For example, 1 means that there in no time lag and 2 means that we skeep
% one trading day before we make a transaction.
% n: number of simulations based on bootstrap.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=cputime;
[Ntrading,nb,ns,yBo,ySo,yB_So,Bo,So,BSo]=rob_TRB(x,H,tax,time_lag);
rt=diff(log(x));
T=length(rt);
M=unidrnd(T,T,n);
rt=rt*ones(1,n);
rb=rt(M);
pb=[x(1)+zeros(1,n);x(1)*cumprod(exp(rb))]; % bootstraped price series
B=zeros(n,1);
S=B;
BS=B;
for i=1:n,
[Ntrading,nb,ns,yb,ys,yb_s,B(i),S(i),BS(i)]=rob_TRB(pb(:,i),H,tax,time_lag);
end
p_B=1/n*sum(B>=Bo);
p_S=1/n*sum(S>=So);
p_BS=1/n*sum(BS>=BSo);
F=[Ntrading,nb,ns,yBo,ySo,yB_So,Bo,So,BSo,p_B,p_S,p_BS]';
cputime-t