在线检测未来函数

蝴蝶原理指标,请帮我完善一下峰谷连线问题

来源:Internet,编辑:股旁网,2012-09-06

编写条件:

最初的源码如图1,最后一个交易日到前一波峰或波谷的连线是没有的,我想补上,假若最后一个交易日收盘在前一波谷以下 就以当日最低和前一波谷最低连线,如图2,假若最后交易日收盘比前一波峰高,就以最后交易日最高价和前一波峰相连,如图3 s1:zig(4,10),colorcyan; polyline(refx(cross(s1,ref(s1,1)),1),l),linedot,coloryellow; polyline(refx(cross(ref(s1,1),s1),1),h),linedot,colormagenta;

编写方法:

 s1:zig(4,10),colorcyan;

polyline(refx(cross(s1,ref(s1,1)),1),l),linedot,coloryellow;
polyline(refx(cross(ref(s1,1),s1),1),h),linedot,colormagenta;
polyline((refx(c,refx(troughbars(4,10,1),date))<l and datacount-refx(troughbars(4,10,1),date)=barpos) or islastbar,l);
polyline((refx(c,refx(peakbars(4,10,1),date))>h and datacount-refx(peakbars(4,10,1),date)=barpos) or islastbar,h);

相关文章