小幫手好
自動交易策略,進場後想要幾天後的幾點出場,要如何寫呢? 嘗試了幾種寫法,回測大多無法出場,或只會出場第一筆,請協助,謝謝
寫法1: 這個方式會出場第一筆,但是第二筆進了之後,就不再出場
if time=093000 and Symbol = "2330.TW" and position=0 then begin
setposition(1)
end;
if position=1 and filled=1 then begin
if datediff(date, filledRecordDate(1))=1 and time=130000 then setposition(0);
end;
寫法2:沒有出場
if time=093000 and Symbol = "2330.TW" and position=0 then begin
setposition(1);
value1=date;
end;
if position=1 and filled=1 then begin
if datediff(date, value1)=1 and time=130000 then setposition(0);
end;

4 評論