(1)你的程式有兩個迴圈,在第一個迴圈使用value1記錄轉折低點的相對位置。更早將估計量賦予value1是無效的。第二個迴圈的value1其實是第二哥迴圈留下來的value1。
(2)你的程式碼有優化空間。你要找的高低點,其實是第一轉折低點左邊第二根K,不需要使用陣列,也不需要跑迴圈。你試試看下列的程式是否可用。
input: Len(100, "最遠K棒數"); // 減少計算範圍
input: Shoulder (8, "N低點", inputkind:=Dict(["3",3],["4",4],["5",5],["6",6],["7",7],["8",8]), quickedit:=true);
setTotalBar(Len);
var: ma5(0);
var: SecondLeftBar(0);
ma5 = average(volume[1], 5);
value1 = getField("估計量", "D");
value2 = swinglowBar(low, Len, Shoulder, Shoulder, 1);
SecondLeftBar = value2 + 2;
if value2 <> -1
and c cross over H[SecondLeftBar]
and c > H[SecondLeftBar] * 1.02
and DateDiff(CurrentDate, Date[SecondLeftBar]) < 60
and value1 / ma5 > 2.5 and volume > 5000
then ret = 1;
2 評論