// 假設您已有進場策略
var: ProfitTarget(50); // 設定獲利點數 (例如: 50點)
var: BreakEvenPrice(0); // 初始化保本價
// 檢查是否持有部位
if Filled > 0 then begin
// 1. 計算保本價: 庫存成本 + 預留的手續費與稅 (可調整)
BreakEvenPrice = FilledAvgPrice + 2;
// 2. 當目前部位獲利超過目標 ProfitTarget
if Close > (FilledAvgPrice + ProfitTarget) then begin
// 3. 保本機制:如果價格回落到保本價以下,全數平倉
if Close <= BreakEvenPrice then begin
SetPosition(0, "市價");
// 平倉 Commentary("觸發保本出場");
end;
end;
end;
照寫後執行有達到條件,但拉回卻沒保本停利,哪裡要修正呢?
6 評論