您好,因為我的交易策略,進場後,持有區間太短,所以我想用quit_in_interval 來間隔,但卻失敗,請問可以如何改進呢? 謝謝。
var: intraBarPersist Quit_in_interval(0); //交易間隔分鐘
var: intraBarPersist last_buy_time(0);
If BarFreq = "min" then begin Quit_in_interval=BarInterval+5; //如果是5分K,應該間隔6分鐘
//間隔一段時間,再進行下一筆交易
if position = 0 and filled = 0 and condition1 = true and currentTime > timeadd (last_buy_time ,"M",Quit_in_interval) then setposition(-1);
last_buy_time =currentTime;
print(date,time,last_buy_time);
end;
//and currentTime >= last_buy_time+1
//停利
if position = -1 and filled = -1 and condition2 =true then setposition(0);
print(date,time,last_buy_time+20);
//停損
if position = -1 and filled = -1 and condition1 =true then setposition(0);
2 評論