以下是我用交易腳本寫的當沖策略,但在執行回測時卻一筆成交紀錄都沒有,且許多個股都出現嘗試除以0的錯誤訊息
回去檢查被放在分母的數值應該都不太可能是0,想請問小幫手是哪裡有問題呢?謝謝
if date<>date[1] then begin
condition1=false;
condition2=false;
end;
input:r1(100000,"下單金額");
var:_amount(0); {變數紀錄下單量,最多10萬}
_amount=Floor(r1/(closeD(1)*1000));
if time>093000 and time<123000 then begin
if volume/volume[1]>15
and close/close[1]<1.01
and close/close[1]>1 {符合條件則記錄當下的high、close}
and high/closeD(1)<1.06 then begin {邏輯是找出爆量但漲不兇的1分K}
value1=close;
value2=high;
end
else return;
end;
if value1<>0 and value2<>0 and close<value1 then begin
condition1=true; {進場條件:跌破value1}
condition2=false;
end;
if condition1=true and close>=value2 then begin
condition1=false; {出場條件:突破value2}
condition2=true;
end;
if position=0 and condition1 then setposition(-_amount, close);
if position=-_amount and condition2 then setposition(_amount, Market);
8 評論