
io preferisco non farlo. Ottimizzato in corso d'opera. Il mio funziona cosi:e dal 2004
input:lung1(70),lung2(0),obbiettivo(1180),stoppe(150),soglia(500),salvaprofitti(150),tolleranza(50);
vars:dema1(0),dema2(0);
vars:trailing(0);
if c cross over xaverage(c,lung1) + tolleranza then begin
buy at close;
end;
if c cross under xaverage(c,lung1) - tolleranza then begin
sell at close;
end;
if marketposition = 1 then begin
exitlong at entryprice + obbiettivo limit;
exitlong at entryprice - stoppe stop;
end;
if marketposition = -1 then begin
exitshort at entryprice - obbiettivo limit;
exitshort at entryprice + stoppe stop;
end;
if marketposition = 1 and c > entryprice + soglia then begin
trailing = 1;
end;
if marketposition = 1 and trailing = 1 then begin
exitlong at entryprice + obbiettivo limit;
exitlong at entryprice + salvaprofitti stop;
end;
if marketposition = -1 then begin
exitshort at entryprice - obbiettivo limit;
exitshort at entryprice + stoppe stop;
end;
if marketposition = -1 and c < entryprice - soglia then begin
trailing = 1;
end;
if marketposition = -1 and trailing = 1 then begin
exitshort at entryprice - obbiettivo limit;
exitshort at entryprice - salvaprofitti stop;
end;
if marketposition = 0 then begin
trailing = 0;
end;