大大們好~~~
小弟想詢問一下
當商品A在 7/10 被B選股策略給選出來 利用交易腳本買進後預計放置 15 天出場。
而商品A又在 7/15 被B選股策略選出來 一樣要放置 15 天出場
按照以下方式撰寫時,會發現出錯,不知道邏輯是哪邊遺漏掉~~
// 第一次買進 ex. 7/10
if Position = 0 and Filled = 0 then SetPosition(1, market);
// 判斷後續是否又出現訊號繼續買進 ex. 7/15
if Position > 0 and Filled > 0 then SetPosition(Position+1, market);
// 撰寫 15 天後出場
if Position > 0 and Filled > 0 then begin
var: idx(0);
for idx = 1 to FilledRecordCount begin
value99 = FilledRecordDate(idx);
if GetBarOffset(value99) = 14 then sell(FilledRecordQty(idx), market);
end;
end;
2 評論