VAR:MioRsi1,miavar(0);
var:MIN,MAX,bb,CC,zona1,mioatr1,mioatr2,min1,max1,zona2;
mioatr1 = RSI(C,3,s);
miorsi1 = MOV(mioatr1,3,s);
MIN = LLV(MOV(mioatr1,3,s),20) < Ref(LLV(MOV(mioatr1,3,s),20),2) AND LLV((miorsi1),20) < 10;
MAX = HHV(MOV(mioatr1,3,s),20) > Ref(HHV(MOV(mioatr1,3,s),20),2) AND HHV((miorsi1),20) > 90;
if MIN = true then
bb =9;
else
bb =2;
endif;
if MAX = TRUE then
CC =9;
else
CC =2;
endif;
//mioRsi1 = RSI(C,14,s);
if positiondir = 0 and BB = 9 then
enterlong(nextbar,Atopen);
endif;
if positiondir =1 and miorsi1 > 25 and C < C[1]then
exitLong(Nextbar,atopen);
endif;
if positiondir = 0 and CC = 9 then
entershort(nextbar,Atopen);
endif;
if positiondir =-1 and miorsi1 < 75 and C > C[1]then
exitShort(Nextbar,atopen);
endif;
zona1=CreateViewport(200,true,true);
PlotChart(MIN,zona1,blue,solid,1);
PlotChart(MAX,zona1,red,solid,1);