--
input:m(3,2,9999); //参数M定位,第1根TBL柱线对应K线的序号
if m<2 then exit;
up:=c>ref(c,1);
down:=c<ref(c,1);
fc:=close;
fo:=open;
a:=setlbound(up,1);
up[1]:=fc[1]>fo[1];
n:=m-1;
if up[n] then begin
B4:=fc[n];
B1:=fo[n];
b3:=B1;
B2:=B1;
tbl:=1;
end else begin
B4:=fo[n];
B1:=fc[n];
B2:=B4;
B3:=B4;
tbl:=0;
end;
tblcount:=1;
////////////////////////////////////
for i=n+1 to datacount do begin
if tbl=1 then begin
if up[i] then begin
if fc[i]>B4 then begin
tblcount:=tblcount+1;
tblc[i]:=fc[i];
tblo[i]:=B4;
if tblcount>2 then begin
tblcount:=3;
B1:=B2;
B2:=B3;
end;
B3:=B4;
B4:=fc[i];
end;
end
else if down[i] then begin
if fc[i]<B1 then begin
tblcount:=1;
tblc[i]:=fc[i];
tblo[i]:=B3;
B1:=fc[i];
B2:=B3;
tbl:=0;
end;
end;
end else begin
if down[i] then begin
if fc[i]<B1 then begin
tblcount:=tblcount+1;
tblc[i]:=fc[i];
tblo[i]:=B1;
if tblcount>2 then begin
tblcount:=3;
B4:=B3;
b3:=B2;
end;
B2:=B1;
B1:=fc[i];
end;
end
else if up[i] then begin
if fc[i]>B4 then begin
tblcount:=1;
tblc[i]:=fc[i];
tblo[i]:=B2;
B4:=fc[i];
B3:=B2;
tbl:=1;
end;
end;
end;
end;
stickline(tblc<>0 and up,tblc,tblo,7,1)colorred;
stickline(tblc<>0 and down,tblc,tblo,7,0),colorcyan;
ts:=barslast(tblc);
stickline(tblc=0 and ref(up,ts),ref(tblc,ts),ref(tblc,ts),3,1),colormagenta;
stickline(tblc=0 and ref(down,ts),ref(tblc,ts),ref(tblc,ts),3,1),colorblue;
cc:tblc,linethick0;
oo:tblo,linethick0;