為什麼使用issessionfirstbar後單一標的還是會觸發多筆回測

  •   171 
  • 最後發表   StockS  2024 三月 19
StockS 發文於   2024/03/18

小幫手你好

我想請問為什麼我使用警示腳本日資料回測模擬逐筆洗價

為什麼使用issessionfirstbar去寫target條件

單一標的一天內卻會觸發多筆交易?

謝謝!

var: intraBarPersist target(0);
condition1 = time <= 110000 and high >= getField("參考價", "D") * 1.07;
condition2 = GetSymbolInfo("買賣現沖") or GetSymbolInfo("先買現沖");
condition3 = getField("Volume", "D") >= 500;

if isSessionFirstBar then target = 0;

if condition1 and condition2 and condition3 and target = 0 then target = 1;
if target = 1 and c cross Under ( getField("參考價", "D") + high) * 0.5
then  begin
    ret = 1;
    target = 2;
end;

XS小編 發文於   2024/03/19

 Hello StockS,

 

isSessionFirstBar 是回傳該根Bar是否為當日的第一根Bar。

日頻率只有一根Bar,所以該根Bar一定會是第一根Bar。

也就是說,if isSessionFirstBar then target = 0; 一定會符合。

故下面的判斷也一定會執行 (target 一直等於0)。

 

另外在日頻率的情況下 time 會是0。

您可以使用 getfield("Time", "1") 或是 currenttime 來取得洗價對應的1分鐘Bar時間。

發表回覆
Close