我試著練習寫選股腳本 - OBV 5日平均線上穿20日平均線
Script如下, 不需要剛好當日上交叉, 只要當日5日線有大於20日線即可
但我使用 plot 畫圖驗證時, 發現有部分選股結果是錯的...
變成5日線在20日線之下...
請問我是否有哪裡寫錯呢?
================================================
variable: obvolume(0);
if CurrentBar = 1 then
obvolume = 0
else
begin
if close > close[1] then
obvolume = obvolume[1] + volume
else
begin
if close < close[1] then
obvolume = obvolume[1] - volume
else
obvolume = obvolume[1];
end;
end;
ret = average(obvolume, 5) >= average(obvolume, 20); //判斷OBV 5日均線是否上穿20日均線
2 評論