寫了一段自動交易程式,想在如果當下時間為 10:00 後,則計算虧損若超過 2000 元則自動出清平倉出場,但是在回測時總是試不出來,也是要到最後每日部位出零,請問語法是否有要修正的地方呢?
variable: cost_price(0), current_profit(0);
if Filled > 0 then begin
cost_price = FilledAvgPrice;
if time >= 100500 then begin
current_profit = Close - cost_price;
if current_profit < -2000 then begin
SetPosition(0, label:="接受虧損出場");
end;
if current_profit > 2000 then begin
SetPosition(0, label:="見好就收出場");
end;
end;
end;
4 評論