確定峰點/谷點的最簡單方法是用ZIG()類函數。(它們屬于“未來函數”,請不要怕)
下面的公式畫峰點的向右水平線。公式簡單,但水平線沒有延長到最右邊。
drawkline(h,o,l,c); {副圖}
P:=20; {P還是作為公式的參數好}
a:=peakbars(H,P,1);
h1:ref(h,a),nodraw; {顯示峰點高度值}
stickline(a>=0,h1,h1,3,0),coloryellow;
畫谷點類似,用troughbars(L,P,1)代替peakbars(H,P,1)即可。
沒有辦法把每條直線延長到最右邊。但可以用笨法子把有限的N條直線延長:重復語句N次。
例如在N=3時,寫:
b:=currbarscount;
a1:=const(peakbars(H,20,1));
h1:if(b<=a1,const(ref(h,a1)),drawnull),coloryellow;
a2:=const(peakbars(H,20,2));
h2:if(b<=a2,const(ref(h,a2)),drawnull),coloryellow;
a3:=const(peakbars(H,20,3));
h3:if(b<=a3,const(ref(h,a3)),drawnull),coloryellow;