Hello 小陽,
是的,會算到前一天的Bar,因為該函數就是抓5根Bar。
您可以用變數計當日算過了幾根Bar,並以此判斷要取多少根Bar的Highest。
還有,成交量大於過去5根Bar應該是 volume > highest(volume[1], 5); 因為 highest 在運算的時候會包含當根Bar。
舉例來說:
if date <> date[1] then value1 = 0; //用value1記錄當天過了幾根Bar
value1 += 1;
if value1 < 6 and value1 > 1 then begin
value2 = simplehighest(volume[1], value1 - 1);
end
else if value1 >= 6 then begin
value2 = simplehighest(volume, 5);
end
else if value1 = 1 then begin
value2 = volume;
end;
if volume > value2 then ret = 1;
需注意 highest 是以節省效能的方式撰寫,後面的期數不能為變數,所以改使用 simplehighest 避免運算錯誤。
3 評論