Pr:=Input(" rsiPeriods",1,300,8);
prk:=Input(" uzakperiods",1,30,5);
IND:=STOFD(pr,5,e);
svy:=ind<1.02*LastValue( ind ) AND ind>0.98*LastValue( ind );
egm:=ind-Ref(ind,-1);
egm2:=If(egm>=0,1,-1);
k1:= if(egm2=LastValue( egm2) AND svy = LastValue( svy ),1,0);
k2:=Cross(k1,0.99);
k3:=ref(k2,-prk);
f2:= ValueWhen(1 ,k3=1 ,Mov(C,prk,E));
fa:=Ref(C,-prk);
p1:=(If(f2-fa<0,1,0));
p2:=If( k3=1 ,p1,0 );
pt:=100*Cum(k3)/(1+cum(1));
pp:=100-100*Cum(p2)/(Cum(k3)+1); pp