股票行情+个股解答
打印

[飞狐] 三价线

三价线

input:m(2,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 then begin
      if fc>B4 then begin
        tblcount:=tblcount+1;
        tblc:=fc;
        tblo:=B4;
        if tblcount>2 then begin
          tblcount:=3;
          B1:=B2;
          B2:=B3;
        end;
        B3:=B4;
        B4:=fc;
      end;
    end
    else if down then begin
      if fc<B1 then begin
        tblcount:=1;
        tblc:=fc;
        tblo:=B3;
        B1:=fc;
        B2:=B3;
        tbl:=0;
      end;
    end;
  end  else begin
    if down then begin
      if fc<B1 then begin
        tblcount:=tblcount+1;
        tblc:=fc;
        tblo:=B1;
        if tblcount>2 then begin
          tblcount:=3;
          B4:=B3;
          b3:=B2;
        end;
        B2:=B1;
        B1:=fc;
      end;
    end
    else if up then begin
      if fc>B4 then begin
        tblcount:=1;
        tblc:=fc;
        tblo:=B2;
        B4:=fc;
        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;

TOP