var: L_signal,S_signal,VAL1,VAL2,indzona1,miomax,miomin,indzona2,ema1,sma1,sma2,OK_LONG,OK_SHORT;
var: miomin,miomax,filtroLong,filtroShort,mioosc1plus,mioosc2min,mioosc3,miomov1;
ema1 = MOV(C,1,e);
sma1 = MOV(C,1,s);
sma2 =MOV(C,20,s);
miomov1 = MOV(C,9,s);
mioosc1plus = DMPDX (C, 8);
mioosc2min = DMNDX (C, 8);
mioosc3 = DMADX (C, 8);
Miomax = HHV(H,20);
Miomin = LLV(L,20);
VAL1 = Miomax-C;
VAL2 = C-Miomin;
if positiondir = 1 THEN
miomax = miomax+val1;
miomin = 0;
endif;
if positiondir = -1 then
miomin = miomin+val2;
miomax = 0;
endif;
if miomax > 0 then
filtroLong = 1;
else
filtroLong = 0;
endif;
if miomin > 0 then
filtroShort = 1;
else
filtroShort = 0;
endif;
if VAL1 < VAL2 then
L_signal = L_signal+1;
colorbar(fuchsia);
S_signal = 0;
else
S_signal = S_signal+1;
colorbar(yellow);
L_signal = 0;
endif;
OK_LONG = C - SMA2;
OK_SHORT = SMA2 - C;
if VAL1 < VAL2 and C > sma2 and VAL1[1] < VAL2[1] and OK_LONG > OK_SHORT then enterlong(Nextbar,atopen);endif;
if VAL1 > VAL2 and C < sma2 and VAL1[1] > VAL2[1] and OK_SHORT > OK_LONG then entershort(NextBar,atopen);endif;
indZona1 = CreateViewport(400,true,true);
PlotChart(filtroshort,indzona1,red,solid,2);
PlotChart(filtrolong,indzona1,blue,solid,2);