當前K觸發無法出清問題。

  •   29 
  • 最後發表   賢仔  2025 七月 25
賢仔 發文於   2025/07/25

小編,教授 您好

請問一下我目前遇到一個問題就是沒辦法再當前K進場後拉升上影線,沒計算出清問題。是否可以幫我解答,謝謝您 附上照片固定停利是1%

以下是出清出清程式碼

// === 出場邏輯(固定停利 / 停損)===

If Position <> 0 and IsFilled = True and (CurrentTimeVar - ppTime > 8) then begin

 

    // 多單

    if Position = 1 then begin

        if high >= MyEntryPrice * (1 + FixedProfitPercent / 100) then begin

            Print("? 多單觸發【固定停利】出場!", Close);

   IsFilled = False;

            SetPosition(0);

        end

        else if Close <= MyEntryPrice * (1 - FixedLossPercent / 100) then begin

            Print("? 多單觸發【固定停損】出場!", Close);

   IsFilled = False;

            SetPosition(0);

        end;

    end;

 

    // 空單

    if Position = -1 then begin

        if low <= MyEntryPrice * (1 - FixedProfitPercent / 100) then begin

            Print("? 空單觸發【固定停利】出場!", Close);

   IsFilled = False;

            SetPosition(0);

        end

        else if Close >= MyEntryPrice * (1 + FixedLossPercent / 100) then begin

            Print("? 空單觸發【固定停損】出場!", Close);

   IsFilled = False;

            SetPosition(0);

        end;

附加文件

排序方式: 標準 | 最新
虎科大許教授 發文於   2025/07/25

不是很懂你的問題及需求。

賢仔 發文於   2025/07/25

教授你 好,就是我設定固定1%停利,假設我131進場同根K拉升到133,這樣就已經觸發1%了,可是他沒觸發出清。

虎科大許教授 發文於   2025/07/25

由於你沒有提供完整的程式碼,我猜測應該是宣告IsFilled時沒有加intrabarpersist造成。

賢仔 發文於   2025/07/25

謝謝 教授。以排除問題的,謝謝

發表回覆
Close