%macro pan(n=80p=20,k=20);
%do a=10 %to %eval(&n);
data adxr (keep= date time close hh2 ll2 hh ll t1);
set a;
retain t0-t%eval(&a-1) 0 f0-f%eval(&a-1) 100000;
%do i=%eval(&a-1) %to 1 %by -1;
t&i=t%eval(&i-1);
%end;
%do i=%eval(&a-1) %to 1 %by -1;
f&i=f%eval(&i-1);
%end;
t0=close;
f0=close;
hh=max(of t0-t%eval(&a-1));
ll=min(of f0-f%eval(&a-1));
hh2=0.97*hh;
ll2=1.03*ll;
a=max(high-low,high-lag(close));
b=abs(low-lag(close));
c=max(a,b);
retain g 0;
g=g+c;
tr=g-lag&a(g);
hd=high-lag(high);
ld=lag(low)-low;
if hd>ld and hd>0 then dmp1=hd;
else dmp1=0;
retain g2 0;
g2=g2+dmp1;
dmp=g2-lag&a(g2);
if ld>hd and ld>0 then dmm1=ld;
else dmm1=0;
retain g3 0;
g3=g3+dmm1;
dmm=g3-lag&a(g3);
pdi=dmp*100/tr;
mdi=dmm*100/tr;
t1=pdi-mdi;
run;
%do b=1 %to &p;
%do c=1 %to &k;
data pan;
set adxr;
if t1<=&b and t1>=0 and hh2-lag&a(hh2)<=0.02*hh2 then y1=1;
else if t1>=-&c and t1<=0 and lag&a(ll2)-ll2<=0.02*ll2 then y1=1;
else y1=0;
data a1;
set pan;
retain m 0;
if y1^=lag(y1) then m=sum(m,1);
run;
proc sql stimer;
create table a2 as
select *,count(m) as sum from a1
group by m
order by date,time;
quit;
data a2;
set a2;
if sum=1 then delete;
run;
data a2;
set a2;
if y1=1;
proc sort data=a2;
by m;
data a3;
set a2;
if last.m;
by m;
run;
proc sql;
select count(y1) as count into : count1 from a3;
quit;
data b1;
set a1;
if y1=0;
run;
proc sort data=b1;
by m;
data b3;
set b1;
if last.m or first.m;
by m;
run;
data b4;
set b3;
if t1<=0 and lag(m)=m then profile=lag(close)-ll;
else if t1>0 and lag(m)=m then profile=hh-lag(close);
else profile=0;
run;
proc sql ;
select sum(profile) as sum into : count2 from b4;
quit;
data count;
n1=&a;
n2=&b;
n3=&c;
count1=&count1;
count2=&count2;
run;
proc append base=one data=count force;
run;
%end;
%end;
%end;
%mend;
%pan;




雷达卡



京公网安备 11010802022788号







