移動停利

  •   114 
  • 最後發表   束束  2025 六月 24
束束 發文於   2025/06/16

多單移動停損與移動停利

If (PositionStatus = 1) Then Begin  

    

    If StopLossPoint = 0 Then Begin  

        StopLossPoint = Entry_Price - MaxDrawdown;  

    End;  

 

    

    If Close > Entry_Price Then Begin  

        If Close - MaxDrawdown > StopLossPoint Then Begin  

            StopLossPoint = Close - MaxDrawdown;  

        End;  

    End;  

 

 

    If Max_Profit = 0 And Close >= Entry_Price + TakeProfit Then Begin  

        Max_Profit = Close;  

    End;  

 

    If Max_Profit <> 0 Then Begin  

        

        If Close <= Max_Profit - ProfitDrawbackPoint Then Begin  

            Sell(1);  

            PositionStatus = 0;  

            StopLossPoint = 0;  

            Max_Profit = 0;  

        End  

        Else If Close > Max_Profit Then Begin  

            Max_Profit = Close;  

        End;  

    End;  

 

 

    If Close <= StopLossPoint Then Begin  

        Sell(1);  

        PositionStatus = 0;  

        StopLossPoint = 0;  

        Max_Profit = 0;  

    End;  

End    

 

為什麼我這段程式無法順利執行移動停利

 

排序方式: 標準 | 最新
XS小編 發文於   2025/06/24

Hello 束束,

 

有可能造成移動停利無法觸發的可能性有很多,舉例來說,同一時間有其他的交易指令觸發 (腳本每次運算最多只會執行一個交易指令),或是變數沒有被宣告為 intrabarpersist,但策略卻用逐筆洗價/定時洗價執行。

建議可以參考系統內建的移動停利腳本。

若還是有問題的話,麻煩提供 自動交易策略匯出檔包含交易腳本 (若是回測的話則是回測的設定) 以及 XQ Log 並告知問題發生的日期時間,讓相關人員確認。

可以透過XQ內的設定 => 問題回報方式來上傳提供,並附上討論區問題連結。

感謝。

虎科大許教授 發文於   2025/06/24

你的問題應該是沒有正確宣告變數造成。貼文上來應該附上這些變數是如何宣告,這樣才有辦法知道真正的原因。

發表回覆
Close