Hello 生生,
once後面少了一個後括號,且不需要then。
細節請參考 Once 的說明。
修改過的腳本如下:
var: intrabarpersist onceperday(0);
variable: tr(0);
tr= ( (close-GetField("最高價","D"))/GetField("最高價","D") )*100;
once(onceperday=0 and GetInfo("IsRealTime") = 1 and tr<=-2) begin
ret=1;
Print(file("C:\print\print.log"),"開盤爆量",FormatDate("yyyy/MM/dd", currentDate),FormatTime("HH:mm:ss", currentTime),symbol,symbolName,"價格",numToStr(,close,2));
oncePerday= currentbar;
end;
另外,您once這樣包的話print和警示都只會執行一次。
如果只有print要執行一次的話,可以這樣寫:
variable: tr(0);
tr= ( (close-GetField("最高價","D"))/GetField("最高價","D") )*100;
if GetInfo("IsRealTime") = 1 and tr<=-2 then begin
ret = 1;
once(True) begin
Print(file("C:\print\print.log"),"開盤爆量",FormatDate("yyyy/MM/dd", currentDate),FormatTime("HH:mm:ss", currentTime),symbol,symbolName,"價格",numToStr(,close,2));
end;
end;
網站上有教學區,裡面有XS語法的基礎和應用。
9 評論