等价k线的实现,之前看到的帖子似乎都要用到vba。
如何在普通的图表上显示等价k线?终于找到一段代码,可以在金字塔副图正常显示。
请版主看下,这样实现出来的等价K线是否准确。有没有未来数据?
INPUT:N(5,1,100);
fc:=c;fo:=o;cc:0*c,PRECISION4,LINETHICK0;oo:0*c,PRECISION4,LINETHICK0;t1:=0*c;t2:=0*c;
for i=1 to datacount do begin
if i=1 and fc[i]>fo[i] then
cc[i]:=fc[i];
oo[i]:=fc[i];
if i=1 and fc[i]<fo[i] then
cc[i]:=fc[i];
oo[i]:=fc[i];
if i>1 then
cc[i]:=cc[i-1];
oo[i]:=oo[i-1];
if i>1 and fc[i]>cc[i]*(1+n/1000) then begin
cc[i]:=cc[i-1]*(1+n/1000);
oo[i]:=cc[i-1];
end;
if i>1 and fc[i]<oo[i]/(1+n/1000) then begin
oo[i]:=oo[i-1]/(1+n/1000);
cc[i]:=oo[i-1];
end;
if oo[i]=oo[i-1] then
t1[i]:=t1[i-1]+1;
if cc[i]=cc[i-1] then
t2[i]:=t2[i-1]+1;
end;
o1:=ref(oo,t1+1);
c1:=ref(cc,t2+1);
格子点数:abs(cc-oo),PRECISION4,linethick0;
STICKLINE(c1=oo,ref(cc,1),ref(oo,1),1,1)COLORRED;
STICKLINE(c1=oo,cc,oo,8,1)COLORRED;
STICKLINE(o1=cc,ref(cc,1),ref(oo,1),1,1)COLORCYAN;
STICKLINE(o1=cc,cc,oo,8,1)COLORCYAN;
[此贴子已经被作者于2016-7-10 22:26:13编辑过]
就是那个参数n,5代表千分之5。
不过感觉这个写法好像有未来数据,尤其在有巨大跳空缺口的时候。
麻烦帮测试一下?
同样是5价差的等价k线,效果差很多,用户还是取用vba实现吧

此主题相关图片如下:1.png