想執行一次停利停損後,停止下單,並每次開盤執行

  •   29 
  • 最後發表   Chun Yi  2 週前
Chun Yi 發文於   2026/07/15

大家好!

最近寫了一個策略,想每天執行一次停利或停損後,就停止下單。

當停止下單後,隔天早上都能自動執行,每天都能自動執行不知道這樣的寫法可不可以:

Var : record(0)

If time=084500 then

record=0

End;

If time>=084500 and time<=134500 and record=0 and position=0 and filled=0 and condition1 then

Setposition(1,market) 進場

End;

If time>=084500 and time<=134500 and record=0 and position=1 and filled=1 and condition2 then begin

Setposition(0,market) 停利

Record=1

End;

If time>=084500 and time<=134500 and record=0 and position=1 and filled=1 and condition3 then begin

Setposition(0,market) 停損

Record=1

End;

排序方式: 標準 | 最新
Chun Yi 發文於   2026/07/15

或者改成執行期間是

If time>=084500 and time<=134200

最後在收盤前

If time=134300 then

Record=0

End;

重新歸零

虎科大許教授 發文於   2026/07/15

策略部位設定為與庫存同步。若使用1分鐘頻率,則可使用下列腳本。若使用日頻率,則將Time改成CurrentTime。

If time>=084500 and time<=134400 then
    begin
        if position=0 and filled=0 and condition1 then Setposition(1,market);
        if position=1 and filled=1 then
            if condition2 or condition3 then Setposition(0,market);
    end;

發表回覆
Close