小幫手好
在交易使用getfield取參考價或漲停價做比較時,有些個股會出現資料為空的錯誤
程式碼在下方,說明如下,
使用上市普通股、日頻率回測近一年
只有condition2的時候,回測一切正常
但只要一加入成交量限制(condition5),就會有些股票出現資料為空的訊息
有嘗試加其他條件,像是價格限制,都沒有問題,但只要一加了成交量,就會出問題
這些條件不是應該獨立不會互相影響的嗎? 感覺很怪
煩請協助了解,謝謝

//漲停判斷
input:tickcount(3, "距離幾個tick漲停");
if close>=0 and close<10 then condition2=(close+0.01*tickcount) > GetField("漲停價","D"); //價格在0~10的股票
if close>=10 and close<50 then condition2=(close+0.05*tickcount) > GetField("漲停價","D"); //價格在10~50的股票
if close>=50 and close<100 then condition2=(close+0.1*tickcount) > GetField("漲停價","D"); //價格在50~100的股票
if close>=100 and close<500 then condition2=(close+0.5*tickcount) > GetField("漲停價","D"); //價格在100~500的股票
if close>=500 and close<1000 then condition2=(close+1*tickcount) > GetField("漲停價","D"); //價格在500~1000的股票
//成交量限制
input:minV(500,"最小成交量");
condition5 = getfield("volume","D")[1]>minV;
//綜合判斷
condition99 = condition2 and condition5;
//進場
if Position = 0 and filled=0 and condition99 then begin
SetPosition(1,Market);
end;
if Position = 0 and filled=0 and condition2 then setposition(1);
If position>0 and filled>0 and (close > filledavgprice*1.08 or close< filledavgprice*0.92) then setposition(0);
3 評論