大智慧新一代自编zigzag指标

Discussion in 'General Topics on Software and Data' started by hylt, Jun 12, 2007.

  1. 我写了段代码画不出来,请哪位帮忙修改指导,谢谢!
    Code:
    input:per(10,3,30,1);
    variable:dir=0,pe=0,pepos=0,tr=0,trpos=0;
    
    if dir=0 then begin
    	if high/llv(low,0)>=(1+per/100) then begin
    		pe:=high;
    		pepos:=barpos;
    		dir:=1;
    	end
    	else if low/hhv(high,0)<=(1-per/100) then begin
    		tr:=low;
    		trpos:=barpos;
    		dir:=-1;
    	end
    end
    
    if dir=1 then begin
    	if high>pe then begin
    		pe:=high;
    		pepos:=barpos;
    	end
    	else if low/pe<=(1-per/100) then begin
    		zz1:drawline(barpos=trpos,low,barpos=pepos,high,2);
    		tr:=low;
    		trpos:=barpos;
    		dir:=-1;
    	end
    end
    
    if dir=-1 then begin
    	if low<tr then begin
    		tr:=low;
    		trpos:=barpos;
    	end
    	else if high/tr<(1+per/100) then begin
    		zz2:drawline(barpos=pepos,high,barpos=trpos,low,2);
    		pe:=high;
    		pepos:=barpos;
    		dir:=1;
    	end
    end;
     
  2. 我发现你一直在研究ZIGZAG。
     
  3. 我方向错误?
     
  4. 不是,ZIGZAG和其他未来函数用得好是很好的。
     
  5. input:per(10,3,30,1);
    variable:dir=0,pe=0,pepos=0,tr=0,trpos=0;

    if dir=0 then begin
    if high/llv(low,0)>=(1+per/100) then begin
    pe:=high;
    pepos:=barpos;
    dir:=1;
    end
    else if low/hhv(high,0)<=(1-per/100) then begin
    tr:=low;
    trpos:=barpos;
    dir:=-1;
    end
    end

    if dir=1 then begin
    if high>pe then begin
    pe:=high;
    pepos:=barpos;
    hy1:1;
    end
    else if low/pe<=(1-per/100) then begin
    zz1:drawline(barpos=trpos,low,barpos=pepos,high,2);
    tr:=low;
    trpos:=barpos;
    dir:=-1;
    end
    end

    if dir=-1 then begin
    if low<tr then begin
    tr:=low;
    trpos:=barpos;
    hy2:2;
    end
    else if high/tr<(1+per/100) then begin
    zz2:drawline(barpos=pepos,high,barpos=trpos,low,2);
    pe:=high;
    pepos:=barpos;
    dir:=1;
    end
    end;
     
  6. 程序转入 if high>pe then begin
    pe:=high;
    pepos:=barpos;
    end
    if low<tr then begin
    tr:=low;
    trpos:=barpos;

    end
    试加了hy1:1; hy2:2;就可以测试出了。
     
  7. 不好意思,俺搞错了。难道是drawline函数的COND1、COND2不支持自定义变量pepos、trpos的调用?
     
  8. zigzag 会不会出现未来数据引用?
     
  9. 是的。正因于此,我才想自编代码改造它。
     
  10. 分析家公式是纯标量的,隐含了一个对k线bar的循环,因此在语句中只能对当前bar根据条件操作,而不能再回头对历史的bar进行操作,因此drawline实际是在当前bar上画一个带起点或终点属性的点,系统最后再根据各点的属性用线连接起来,而不能直接画一条跨多个bar的直线.因此在逻辑上不用未来数据是不可能实现的,因为当波峰(谷)得到确认的时候在隐含循环中已经过了波峰(谷)所在的bar了,因而来不及在图形上将波峰(谷)标出来了.
     
  11. 原来如此,谢谢itfin!
     
  12. 清扬写过这个Zig的代码,发表在博庭BBS上。我记性很好,过目不忘,但是密码除外。

    清扬大侠,出手否?
     
  13. 如果画图来说,可以用backset和filter函数实现。如果作为系统信号,就不用了。
    清扬的波浪公式是大波浪套小波浪,画得非常精致,当时wilson说清扬真是天才!