spe spe spe
if picchiotrend>25 then
valactive=4.0;
valtrailing=2.50;
endif;
if picchiotrend<25 then
valactive=2.0;
valtrailing=1.50;
endif;
però così su posizione aperta de l'adx va sopra o sotto soglia ti cambia il trailing.........che non mi pare molto sensato.....
var:ma,mi,valtrailing,miovt,coloretr,coloretrprec,colorenow,valactive,trailon,madx;
if positiondir = 0 then
madx=dmadx(c,9);
if madx >=25 then
valtrailing=2;
valactive=4;
else
valtrailing=1;
valactive=2;
endif;
endif;
//Sezione di ingresso
if t = 900 and c > o then
enterlong(nextbar,atopen);
ma=h;
endif;
if t = 900 and c < o then
entershort(nextbar,atopen);
mi=l;
endif;
//controllo nuovi minimi/massimi
if positiondir = 1 then
if h[1] > ma then
ma=h[1];
endif;
endif;
if positiondir = -1 then
if l[1] < mi then
mi=l[1];
endif;
endif;
if positiondir =1 and h > positionvalue+(positionvalue*valactive/100) and trailon = 0 then
trailon=1;
endif;
if positiondir =-1 and l < positionvalue-(positionvalue*valactive/100) and trailon=0 then
trailon=-1;
endif;
//controllo rottura livello trailing
if c <= ma-(ma*valtrailing/100) and positiondir = 1 and trailon = 1 then
exitlong(bar,atclose);
endif;
if c > mi+(mi*valtrailing/100) and positiondir = -1 and trailon= -1 then
exitshort(bar,atclose);
endif;
if positiondir = 0 then
trailon=0;
endif;
//sezione di uscita
if t=1725 then
exitlong(nextbar,atopen);
exitshort(nextbar,atopen);
endif;
//PLOT TRAILING
if valtrailing <> 0 then
if PositionDir = 1 then
miovt = ma-(ma*valtrailing/100);
if trailon <>0 then
coloreTr = green;
endif;
if trailon = 0 then
coloreTr = red;
endif;
elseif PositionDir = -1 then
miovt = mi+(mi*valtrailing/100);
if trailon <> 0 then
coloreTr = green;
endif;
if trailon = 0 then
coloreTr = red;
endif;
else
coloreTr = white;
endif;
else
miovt = miovt;
coloreTr = fuchsia;
endif;
if coloreTrPrec = white then
colorenow = coloreTrPrec;
else
colorenow = coloreTr;
endif;
plotchart(miovt, 0, colorenow, solid, 2);
coloreTrPrec = coloreTr;