array:orariomassimi[20000](0),orariominimi[20000](0);
var:barramassimo(0),barraminimo(0),contagiorni(0),massimo(0),minimo(0),contabarre(0),maxcandele(0),
path("c:\statistiche\");
if barnumber=1 then begin
FileDelete(path+"stats_"+getsymbolname+".txt");
contagiorni=0;
barramassimo=0;
barraminimo=0;
massimo=0;
minimo=9999999;
end;
if date<>date[1] then begin
contagiorni=contagiorni+1;
if contabarre>maxcandele then maxcandele=contabarre;
contabarre=0;
orariomassimi[barramassimo]=orariomassimi[barramassimo]+1;
orariominimi[barraminimo]=orariominimi[barraminimo]+1;
barramassimo=0;
barraminimo=0;
massimo=0;
minimo=9999999;
end;
if massimo<h then begin
massimo=h;
barramassimo=contabarre;
end;
if minimo>l then begin
minimo=L;
barraminimo=contabarre;
end;
contabarre=contabarre+1;
if LastBarOnChart then begin
FileAppend(path+"stats_"+getsymbolname+".txt","Giorni Totali: "+ numtostr(contagiorni,0)+newline);
FileAppend(path+"stats_"+getsymbolname+".txt","Barra Massimi Minimi"+newline);
for value1=0 to maxcandele-1 begin
value2=orariomassimi[value1];
FileAppend(path+"stats_"+getsymbolname+".txt","Barra"+numtostr(value1,0)+" "+numtostr(value2,0));
value2=orariominimi[value1];
FileAppend(path+"stats_"+getsymbolname+".txt"," "+numtostr(value2,0)+NewLine);
end;
end;