請問小幫手,策略雷達設定日頻率+逐筆+連續觸發
如何做到符合條件時能夠間隔時間在觸發,謝謝
if condition1
then begin
ret=1
end;
請問小幫手,策略雷達設定日頻率+逐筆+連續觸發
如何做到符合條件時能夠間隔時間在觸發,謝謝
if condition1
then begin
ret=1
end;
Hello ItsYeLizard,
您可以使用變數紀錄觸發當下的 currenttime,然後再以 TimeDiff 計算當下和上次觸發的時間差。
舉例來說:
var: intrabarpersist time_record(0);
condition1 = 觸發條件;
condition2 = time_record = 0 or (currenttime > time_record and timediff(currenttime, time_record, "M") > 5) or time_record > currenttime;
// time_record = 0 ==> 第一次觸發
// (currenttime > time_record and timediff(currenttime, time_record, "M") > 5) ==> 間隔大於5分鐘
// time_record > currenttime ==> 換日後第一次執行
if condition1 and condition2 and getinfo("TradeMode") = 1 then begin
ret = 1;
time_record = currenttime;
end;
1 評論