如何撰寫特定時間後觸發某條件

  •   71 
  • 最後發表   catlover999  2022 九月 06
catlover999 發文於   2022/08/30

如題

原本是想寫說

if time>093000 and q_BestBid1>=open then ret=1;

但這樣好像變成系統會在9:30後通知我所有曾經突破開盤價的股票

如果想寫的是9:30後 買方第一檔才突破開盤價的股票請問要如何撰寫

XQ小幫手 發文於   2022/09/06

Hello catlover999,

 

您可以用變數來記錄條件是否有達成。

舉例來說:

var: intrabarpersist _cond1(0), intrabarpersist _cond2(0);

if issessionfirstbar then begin

    _cond1 = 0;

    _cond2 = 0;

    end;

 

if q_BestBid1 >= open then _cond1 = 1;

if currenttime < 093000 and _cond1 = 1 then _cond2 = 1;   //如果 9:30 一前有發生突破的話 _cond2 就為1

if currenttime > 093000 and q_BestBid1 >= open and _cond2 = 0 then ret = 1;  //如果 9:30 以前沒突破,9:30以後發生突破就警示

發表回覆
Close