VAR1:=(HHV(CLOSE,10)-LLV(C,10))*0.999;
VAR2:=IF((C>(LLV(C,10)+VAR1) OR C>LLV(C,10)*1.1) AND C=HHV(C,5) AND C>REF(C,1),1,0);
VAR3:=IF((C<(HHV(C,10)-VAR1) OR C<HHV(C,10)*0.9) AND C=LLV(C,5) AND C<REF(C,1),1,0);
VAR4:=IF(VAR2=1,1,IF(VAR3=1,0,2));
VAR5:=VAR4=1 AND REF(VAR4,1)!=1;
VAR8:=VAR4=0 AND REF(VAR4,1)!=0;
VAR9:=IF(BARSLAST(VAR5)>BARSLAST(VAR8),0,1);
XG:VAR9=1 AND REF(VAR9,1)=0;