发个指标箱的!
DRAWGBK(1,COLORRGB(44,22,108),COLORRGB(33,0,0),0),color10000;
fh:=high;
fl:=low;
sell:=0*fh;
buy:=sell;
signal:=sell;
boxh:sell,linethick0;
boxl:sell,linethick0;
variable:hc=0,lc=0,bt=fh[1],bb=fh[1];
for i=1 to datacount do begin
if hc>1 then begin
if lc>2 and bt<=fh[i] then begin
buy[i]:=1;
for j=i-1 downto i-hc do begin
boxh[j]:=fh[i-hc];
boxl[j]:=fl[i-lc];
end;
hc:=0;lc:=0;
end;
if bt>fh[i] then begin
if lc>2 then begin
if bb>=fl[i] then begin
sell[i]:=1;
for j=i-1 downto i-hc do begin
boxh[j]:=fh[i-hc];
boxl[j]:=fl[i-lc];
end;
hc:=-1;lc:=0;
end else begin
boxh[i]:=fh[i-hc];
boxl[i]:=fl[i-lc];
end;
end;
hc:=hc+1;
if lc>1 then begin
if bb<fl[i] then begin
lc:=lc+1;
if lc=3 then begin
signal[i-hc+1]:=1;
for j=i downto i-hc+1 do begin
boxh[j]:=fh[i-hc+1];
boxl[j]:=fl[i-lc+1];
end;
end;
end else lc:=0;
end else
if lc=1 then begin
if bb<fl[i] then begin
lc:=lc+1;
end else lc:=0;
end;
if lc=0 and hc>1 then begin
bb:=fl[i];
lc:=lc+1;
end;
end else begin hc:=0; lc:=0; end;
end else
if hc=1 then begin
if bt>fh[i] then
hc:=hc+1
else begin hc:=0;lc:=0; end;
end;
if hc=0 then begin
bt:=fh[i];
hc:=hc+1;
end;
end;
partline(boxh and boxh=ref(boxh,1),boxh),coloryellow,pointdot;
partline(boxl and boxl=ref(boxl,1),boxl),coloryellow,pointdot;
partline(boxl and boxl=ref(boxl,1),(boxl+boxh)/2),coloryellow,pointdot;
stickline((signal||refx(buy||sell,1))&&boxh,boxh,boxl,0.1,0),pointdot,coloryellow;
drawicon(buy,low*0.99,4);
drawicon(sell,high*1.01,5);
{--------------------------------------------------------------------------------------------------}
{--------------------------------------------------------------------------------------------------}
boxhl:=(boxl+boxh)/2;
hac:=c;
{ha:=1;}
variable:ha=1;
for i=2 to datacount do
begin
if boxh[i-1]=0 and boxh[i] >0 and (boxh[i] <>boxh[i-1] or boxl[i] <>boxl[i-1]) then hac[i]:=0;
if boxh[i-1]>0 and boxh[i] >0 and (boxh[i] <>boxh[i-1] or boxl[i] <>boxl[i-1]) then hac[i]:=0;
if boxh[i-1]>0 and boxh[i] >0 and boxh[i] =boxh[i-1] and boxl[i] <>boxl[i-1] then hac[i]:=0;
if boxh[i-1]>0 and boxh[i] >0 and boxh[i] =boxh[i-1] and boxl[i] =boxl[i-1] then hac[i]:=ha;
if boxh[i-1]>0 and boxh[i] >0 and boxh[i] =boxh[i-1] and boxl[i] <>boxl[i-1] then hac[i]:=ha;
if boxh[i-1]>0 and boxh[i] >0 and boxh[i] =boxh[i-1] and boxh[i-2]=boxh[i-1] then hac[i]:=hac[i-1]+ha;
if boxh[i-1]>0 and boxh[i]=0 then hac[i]:=0;
if boxh[i-1]=0 and boxh[i]=0 then hac[i]:=0;
end;
nv:=hac;
nvh:=hac;
nvhi:=hac;
nvl:=hac;
nvli:=hac;
kk:=hac[1];
ll:=hac[1];
llt:=hac[1];
mm:=hac[1];
mmt:=hac[1];
mmu:=hac[1];
for i=2 to datacount do
begin
nvh[i]:=0;
nvhi[i]:=0;
nvl[i]:=0;
nvli[i]:=0;
end;
for i=2 to datacount do
begin
if hac[i-1] =0 and hac[i]>0 then kk:=i-1;
if hac[i-1] >0 and hac[i]>0 then llt:=i-1;
if hac[i-1] >0 and hac[i]>0 then for j=kk to llt do nv[j]:=hac[i]+1;
if hac[i-1] =0 and hac[i]>0 then nvhi[i]:=i;
if hac[i-1] =0 and hac[i]>0 then nvh[i]:=boxh[i];
if hac[i-1] =0 and hac[i]>0 then nvl[i]:=boxl[i];
if hac[i-1] >0 and hac[i]=0 then ll:=i-1;
if hac[i-1] >0 and hac[i]=0 then for j=kk to ll do nv[j]:=hac[i-1]+1;
if hac[i-1] >0 and hac[i]=0 then nvli[i-1]:=i-1;
end;
{--------------------------------------------------------------------------------------------------}
{xx:=nv,linethick3;}
{nvhi/500;}
{nvli/400;}
{hh1:=boxh,linethick2;}
{ll1:=boxl;}
{ha:=nvhi; }
{hb:=nvli;}
{fc:=c;}
{--------------------------------------------------------------------------------------------------}
hac[1]:=0;
ahd:=nv;
ahdh:=nvh;
ahdl:=nvl;
ahdnv:=nv;
att1:=hac[1];
att2:=hac[1];
att3:=hac[1];
att4:=hac[1];
atta:=hac[1];
bhd:=nv;
bhdh:=nvh;
|