頻率3分鐘、沒有勾逐筆洗價、啟動後只觸發一次,執行商品5425。
我想抓取3分鐘K線開盤的第一根K棒與第二根K棒的櫃買價格、商品價格與均價,然後在第二根跑完(9:06)開始執行,print結果有誤,currentbar抓取的數字是7,應該是要2,也因此價格也不是第1.2根K的
variable: BarNumberOfToday(0);
variable: otcclose(0);
variable: avp(0);
settotalbar(5);
if Barinterval=3 and barfreq ="Min" then begin //適用於3分鐘線
otcclose = GetSymbolField("OTC.TW","收盤價");
avp = GetField("均價");
if Date <> Date[1] then
BarNumberOfToday=1
else
BarNumberOfToday+=1;{記錄今天的Bar數}
if BarNumberOfToday=2 then begin
Print(NumToStr(date, 0) , NumToStr(time,0), BarNumberOfToday, currentBar, otcclose[currentBar -1], otcclose[currentBar -2], close[currentBar -1], close[currentBar -2], avp[currentBar -1], avp[currentBar -2]);
end;
end;
1 評論