天猫鼠标经过变换图片:顾比倒数线-金字塔实现的顾比倒数线(Z)

来源:百度文库 编辑:中财网 时间:2024/05/11 00:43:06

顾比倒数线,以下跌趋势为例,如果寻找顾比倒数线:

    首先找到下跌趋势线的最低点(标注为1的那条蜡烛线),这是第一只“重要的蜡烛线”。然后沿着这条蜡烛线向左移动,直到遇见另一只“最高价高于蜡烛线1”的蜡烛线,这就是我们要找的第二只“重要的蜡烛线”。再沿着这只蜡烛线向左移动,直到遇见下一只“最高价的蜡烛线”,这就是第三只“重要的蜡烛线”。此时,沿着第三只蜡烛线的顶端画一条直线,这就是“顾比倒数线”;

    上升曲线同理!

 

以前看过一个文华版本的顾比倒数线,用了很大蝙蝠的代码。

 

金字塔只要10行。以下代码把每根K线图的“第三只重要蜡烛线”的高点、低点全部计算出来了

逐K线模式和序列模式均适用:

 

DISTL:=NEWLBARS(L,1);
DISTH:=NEWHBARS(H,1);
HI20:=REF(HHV(H,20),1);
LO20:=REF(LLV(L,20),1);
GBD1:=REF(L,DISTL);
GBD2:=REF(GBD1,DISTL);
GBD:IF(GBD2>0,MAX(LLV(L,20),GBD2),LLV(L,20));//第三只重要蜡烛线的低点

GBG1:=REF(H,DISTH);
GBG2:=REF(GBG1,DISTH);
GBG:IF(GBG2>0,MIN(HHV(H,20),GBG2),HHV(H,20));//第三只重要蜡烛线的高点

 

注意:如果第三只重要的蜡烛线找不到的话(比如第二只已经是历史最高点或者最低点),就用20周期的高点(低点)代替

 

顾比倒数线一般用于止损,和均线等指标配合,也可用于止盈

比如:进场后,5个点止损,浮动盈利达到15个点后,启动顾比倒数线止损。具体用法大家各自发挥

申请加精!

我是把2条线都做出来,定义好趋势后,自行按需调用

看来不懂的人还是挺多,我这里给个实例吧

 

variable:zs=c,maxhl=c;

//把以上顾比线的代码复制一下
DISTL:=NEWLBARS(L,1);
DISTH:=NEWHBARS(H,1);
HI20:=REF(HHV(H,20),1);
LO20:=REF(LLV(L,20),1);
GBD1:=REF(L,DISTL);
GBD2:=REF(GBD1,DISTL);
GBD:=IF(GBD2>0,MAX(LLV(L,20),GBD2),LLV(L,20));

GBG1:=REF(H,DISTH);
GBG2:=REF(GBG1,DISTH);
GBG:=IF(GBG2>0,MIN(HHV(H,20),GBG2),HHV(H,20));
nn:=barslast(date<>ref(date,1))+1;
entertime:=nn>=m and time<=144500;
exittime:=time>=150900;
if holding>0 then 止损1:zs;
if holding<0 then 止损2:zs;
ma5:=ma(c,5);
ma30:=ma(c,30);
long:=cross(ma5,ma30);//多单进场条件
short:=cross(ma30,ma5);//空单进场条件

 

//下破移动止损线后离场
if holding>0 and (cif holding<0 and (c>zs or exittime) then sellshort(1,1,limitr,c);

 

//开仓语句

if holding=0 and entertime and long then begin
 buy(1,1,limitr,c);
 zs:=gbd;//调用顾比倒数线做为止损
 maxhl:=h;//记录当时的高点
end

 

if holding=0 and entertime and short then begin
 buyshort(1,1,limitr,c);
 zs:=gbg;//调用顾比倒数线做为止损
 maxhl:=L;
end

 

if holding<0 and l//创新低后,重新定位离场位,以实现浮动止损
 maxhl:=l;
 zs:=gbg;
end

 

if holding>0 and h>maxhl then begin //创新高后,重新定位离场位,以实现浮动止损
 zs:=gbd;
 maxhl:=h;
end

能否请老师把这个转换为金字塔的?   Post By:2011-4-30 17:55:37

//飞狐顾比倒数源码公式:
ff:=l;
fhf:=h;
fgf:=h;
ftf:=l;
fdf:=l;
zdtf:=c;
zqf:=c;
zqtf:=c;
{顾比倒数进场}
<%
f=ffl.vardata("ff")
fh=ffl.vardata("fhf")
fg=ffl.vardata("fgf")
ft=ffl.vardata("ftf")
fd=ffl.vardata("fdf")
zq=ffl.vardata("zqf")
zqt=ffl.vardata("zqtf")
zdt=ffl.vardata("zdtf")

zq(1)=0
zq(2)=0
zqt(1)=0
zqt(2)=0
tj=0
n=ubound(f)
for i=2 to n
k1=0
k2=0
k3=0
ii=i-2
for j=ii to 2 step -1
  if f(j)    k1=j
    exit for
  end if
next
j=k1-1

while j>=0 and tj=0
  if fh(j)>fh(k1)  then
    k2=j
    tj=1
  else
    j=j-1
  end if
wend

  j=k2-1
  tj=0
while j>=0 and tj=0
   if fh(j)>fh(k2)   then
    k3=j
    tj=1
   else
    j=j-1
   end if
wend
 
if k3>0 then
  fg(i)=fh(k3)
  zq(i)=k3
else
  fg(i)=fg(i-1)
  zq(i)=zq(i-1)+1
end if
next

ffl.vardata("fgf")=fg
ffl.vardata("zqf")=zq

'止损线'
for i=2 to n
k1=0
k2=0
k3=0
ii=i-2
for j=ii to 2 step -1
  if fh(j)>fh(j-1) and fh(j)>fh(j-2) and fh(j)>fh(j+1) and fh(j)>fh(j+2)  then
   k1=j
   exit for
  end if
next
tj=0
j=k1-1
while j>=0 and tj=0
  if fh(j) then
   k2=j
   tj=1
  else
   j=j-1
  end if
wend
if k2>0 then
  fd(i)=fh(k2)
  zdt(i)=k2
else
  fd(i)=fd(i-1)
  zdt(i)=zdt(i-1)+1
end if
j=k2-1
tj=0
while j>0 and tj=0
  if fh(j) then
   k3=j
   tj=1
  else
   j=j-1
  end if
wend

if k3>0 then
  ft(i)=fh(k3)
  zqt(i)=k3
else
  ft(i)=ft(i-1)
  zq(i)=zqt(i-1)+1
end if 
next
ffl.vardata("ftf")=ft
ffl.vardata("fdf")=fd
ffl.vardata("zqtf")=zqt
ffl.vardata("zdtf")=zdt
%>

止赢线:ftf,linethick1,colorwhite,LINEDOT;//如果想把止损位提高,可选第二根K线做参考线,把ftf改成fdf就可以了;
顾比倒数:fgf,COLORGREEN;//,LINEDOT


http://www.weistock.com/bbs/dispbbs.asp?boardid=10&id=6337&page=0&star=1

 

h11:=high;
l11:=low;
a:=ifelse(high>=ref(high,1)&&high>=ref(high,2)&&high>=ref(high,3) &&high>=ref(high,4)&&high>=ref(high,5),low,0);
b:=ifelse(low<=ref(low,1)&&low<=ref(low,2)&&low<=ref(low,3) &&low<=ref(low,4)&&low<=ref(low,5),high,888888);
p1:=ifelse(a>ref(l11,1),ref(l11,1),0);
p2:=ifelse(a>ref(l11,2)&&a<=ref(l11,1),ref(l,2),0);
p3:=ifelse(a>ref(l11,3)&&a<=ref(l11,1)&&a<=ref(l11,2),ref(l11,3),0);
p4:=ifelse(a>ref(l11,4)&&a<=ref(l11,1)&&a<=ref(l11,2)&&a<=ref(l11,3),ref(l11,4),0);
p5:=ifelse(a>ref(l11,5)&&a<=ref(l11,1)&&a<=ref(l11,2)&&a<=ref(l11,3)&&a<=ref(l11,4),ref(l11,5),0);
p6:=ifelse(a>ref(l11,6)&&a<=ref(l11,1)&&a<=ref(l11,2)&&a<=ref(l11,3)&&a<=ref(l11,4)&&a<=ref(l11,5),ref(l11,6),0);
p7:=ifelse(a>ref(l11,7)&&a<=ref(l11,1)&&a<=ref(l11,2)&&a<=ref(l11,3)&&a<=ref(l11,4)&&a<=ref(l11,5)&&a<=ref(l11,6),ref(l11,7),0);
p8:=ifelse(a>ref(l11,8)&&a<=ref(l11,1)&&a<=ref(l11,2)&&a<=ref(l11,3)&&a<=ref(l11,4)&&a<=ref(l11,5)&&a<=ref(l11,6)&&a<=ref(l11,7),ref(l11,8),0);
p9:=ifelse(a>ref(l11,9)&&a<=ref(l11,1)&&a<=ref(l11,2)&&a<=ref(l11,3)&&a<=ref(l11,4)&&a<=ref(l11,5)&&a<=ref(l11,6)&&a<=ref(l11,7)&&a<=ref(l11,8),ref(l11,9),0);
p10:=ifelse(a>ref(l11,10)&&a<=ref(l11,1)&&a<=ref(l11,2)&&a<=ref(l11,3)&&a<=ref(l11,4)&&a<=ref(l11,5)&&a<=ref(l11,6)&&a<=ref(l11,7)&&a<=ref(l11,8)&&a<=ref(l11,9),ref(l11,10),0);
aa:=p1+p2+p3+p4+p5+p6+p7+p8+p9+p10;
pp1:=ifelse(aa>ref(l11,1),ref(l11,1),0);
pp2:=ifelse(aa>ref(l11,2)&&aa<=ref(l11,1),ref(l11,2),0);
pp3:=ifelse(aa>ref(l11,3)&&aa<=ref(l11,1)&&aa<=ref(l11,2),ref(l11,3),0);
pp4:=ifelse(aa>ref(l11,4)&&aa<=ref(l11,1)&&aa<=ref(l11,2)&&aa<=ref(l11,3),ref(l11,4),0);
pp5:=ifelse(aa>ref(l11,5)&&aa<=ref(l11,1)&&aa<=ref(l11,2)&&aa<=ref(l11,3)&&aa<=ref(l11,4),ref(l11,5),0);
pp6:=ifelse(aa>ref(l11,6)&&aa<=ref(l11,1)&&aa<=ref(l11,2)&&aa<=ref(l11,3)&&aa<=ref(l11,4)&&aa<=ref(l11,5),ref(l11,6),0);
pp7:=ifelse(aa>ref(l11,7)&&aa<=ref(l11,1)&&aa<=ref(l11,2)&&aa<=ref(l11,3)&&aa<=ref(l11,4)&&aa<=ref(l11,5)&&aa<=ref(l11,6),ref(l11,7),0);
pp8:=ifelse(aa>ref(l11,8)&&aa<=ref(l11,1)&&aa<=ref(l11,2)&&aa<=ref(l11,3)&&aa<=ref(l11,4)&&aa<=ref(l11,5)&&aa<=ref(l11,6)&&aa<=ref(l11,7),ref(l11,8),0);
pp9:=ifelse(aa>ref(l11,9)&&aa<=ref(l11,1)&&aa<=ref(l11,2)&&aa<=ref(l11,3)&&aa<=ref(l11,4)&&aa<=ref(l11,5)&&aa<=ref(l11,6)&&aa<=ref(l11,7)&&aa<=ref(l11,8),ref(l11,9),0);
pp10:=ifelse(aa>ref(l11,10)&&aa<=ref(l11,1)&&aa<=ref(l11,2)&&aa<=ref(l11,3)&&aa<=ref(l11,4)&&aa<=ref(l11,5)&&aa<=ref(l11,6)&&aa<=ref(l11,7)&&aa<=ref(l11,8)&&aa<=ref(l11,9),ref(l11,10),0);
aaa:=pp1+pp2+pp3+pp4+pp5+pp6+pp7+pp8+pp9+pp10;
c11:=valuewhen(aaa>0,aaa);
t1:=ifelse(bt2:=ifelse(b=ref(h11,1),ref(h11,2),0);
t3:=ifelse(b=ref(h11,1)&&b>=ref(h11,2),ref(h11,3),0);
t4:=ifelse(b=ref(h11,1)&&b>=ref(h11,2)&&b>=ref(h11,3),ref(h11,4),0);
t5:=ifelse(b=ref(h11,1)&&b>=ref(h11,2)&&b>=ref(h11,3)&&b>=ref(h11,4),ref(h11,5),0);
t6:=ifelse(b=ref(h11,1)&&b>=ref(h11,2)&&b>=ref(h11,3)&&b>=ref(h11,4)&&b>=ref(h11,5),ref(h11,6),0);
t7:=ifelse(b=ref(h11,1)&&b>=ref(h11,2)&&b>=ref(h11,3)&&b>=ref(h11,4)&&b>=ref(h11,5)&&b>=ref(h11,6),ref(h11,7),0);
t8:=ifelse(b=ref(h11,1)&&b>=ref(h11,2)&&b>=ref(h11,3)&&b>=ref(h11,4)&&b>=ref(h11,5)&&b>=ref(h11,6)&&b>=ref(h11,7),ref(h11,8),0);
t9:=ifelse(b=ref(h11,1)&&b>=ref(h11,2)&&b>=ref(h11,3)&&b>=ref(h11,4)&&b>=ref(h11,5)&&b>=ref(h11,6)&&b>=ref(h11,7)&&b>=ref(h11,8),ref(h11,9),0);
t10:=ifelse(b=ref(h11,1)&&b>=ref(h11,2)&&b>=ref(h11,3)&&b>=ref(h11,4)&&b>=ref(h11,5)&&b>=ref(h11,6)&&b>=ref(h11,7)&&b>=ref(h11,8)&&b>=ref(h11,9),ref(h11,10),0);
bb:=ifelse((t1+t2+t3+t4+t5+t6+t7+t8+t9+t10)=0,888888,t1+t2+t3+t4+t5+t6+t7+t8+t9+t10);
tt1:=ifelse(bbtt2:=ifelse(bb=ref(h11,1),ref(h11,2),0);
tt3:=ifelse(bb=ref(h11,1)&&bb>=ref(h11,2),ref(h11,3),0);
tt4:=ifelse(bb=ref(h11,1)&&bb>=ref(h11,2)&&bb>=ref(h11,3),ref(h11,4),0);
tt5:=ifelse(bb=ref(h11,1)&&bb>=ref(h11,2)&&bb>=ref(h11,3)&&bb>=ref(h11,4),ref(h11,5),0);
tt6:=ifelse(bb=ref(h11,1)&&bb>=ref(h11,2)&&bb>=ref(h11,3)&&bb>=ref(h11,4)&&bb>=ref(h11,5),ref(h11,6),0);
tt7:=ifelse(bb=ref(h11,1)&&bb>=ref(h11,2)&&bb>=ref(h11,3)&&bb>=ref(h11,4)&&bb>=ref(h11,5)&&bb>=ref(h11,6),ref(h11,7),0);
tt8:=ifelse(bb=ref(h11,1)&&bb>=ref(h11,2)&&bb>=ref(h11,3)&&bb>=ref(h11,4)&&bb>=ref(h11,5)&&bb>=ref(h11,6)&&bb>=ref(h11,7),ref(h11,8),0);
tt9:=ifelse(bb=ref(h11,1)&&bb>=ref(h11,2)&&bb>=ref(h11,3)&&bb>=ref(h11,4)&&bb>=ref(h11,5)&&bb>=ref(h11,6)&&bb>=ref(h11,7)&&bb>=ref(h11,8),ref(h11,9),0);
tt10:=ifelse(bb=ref(h11,1)&&bb>=ref(h11,2)&&bb>=ref(h11,3)&&bb>=ref(h11,4)&&bb>=ref(h11,5)&&bb>=ref(h11,6)&&bb>=ref(h11,7)&&bb>=ref(h11,8)&&bb>=ref(h11,9),ref(h11,10),0);
bbb:=tt1+tt2+tt3+tt4+tt5+tt6+tt7+tt8+tt9+tt10;
d:=valuewhen(bbb>0,bbb);
ud:=ifelse(close>d&&ref(close,1)<=d,1,ifelse(close=c11,-3,0));
k:=valuewhen(ud<>0,ud);
g:=ifelse(k=1,c11,d),colorred;
g1:=valuewhen(islastbar,g);
tmp:=-k;
//tmp>0,spk;
//tmp<=0,bpk;

if holding=0 then begin
 if tmp<=0 then
  buy(1,1,limitr,close);
end

if holding=0 then begin
 if tmp>0 then
  buyshort(1,1,limitr,close);  
end

if holding>0 then begin
 if tmp>0 then begin
  sell(1,holding,limitr,close);
  buyshort(1,1,limitr,close);
 end
end

if holding<0 then begin
 if tmp<=0 then begin
  sellshort(1,holding,limitr,close);
  buy(1,1,limitr,close);
 end
end
    
收益:asset,noaxis,colorred;
次数:totaltrade,linethick0;
胜率:percentwin,linethick0;
连亏:maxseqloss,linethick0;
连赢:maxseqwin,linethick0;
http://www.weistock.com/bbs/dispbbs.asp?boardid=10&Id=5300&page=2