計算次數警示問題

  •   330 
  • 最後發表   sAAAs  2022 三月 11
sAAAs 發文於   2022/03/10

不好意思又來麻煩小幫手了

如題 當沖警示

value1 = getField("最高價", "D");
value2 = (high-low[1])/low[1]*100;

value3 = (high-low[1])/low[1]*100;

if  Barinterval=1 and barfreq ="Min"
and date <> date[1] then Begin

 

if time > 090500 and time < 100000//十點之前

and high = value6//創新高
and value2 > 1.5//漲1.5%

計算滿3次後警示的腳本如何寫呢?

爬了很多資料 試寫了很多次 實在不行才來請教

是用while 來寫嗎?

用意是想急漲創新高後三次在空它

variable: n(0);
variable: count(0);

if  Barinterval=1 and barfreq ="Min"  then Begin

value1 = getField("最高價", "D");
value2 = (openD(0)-closeD(1))/closeD(1);
value3 = (high-low[1])/low[1]*100;
condition1=false;

if time > 090500

then begin

 if high = value1
 and value3 > 1
 and value2 >= 0 and value2 < 0.01
 then condition1=true;
 
n = 1;
    while n <=3  begin //以下的陳述(到end;為止),n=1執行一次,n=2執行一次,一直到n=3
if condition1 then
        count+=1;
        n = n + 1;
        
    end;
end;

//設定警示條件:if.. then ret=1;
if count = 3 and time < 100000
then ret=1;
end;

為什麼有些隔天一開盤會警示進場呢?

 

 

 

排序方式: 標準 | 最新
XQ小幫手 發文於   2022/03/11

Hello sAAAs,

 

您可以用變數來記錄,舉例來說上述腳本中計算次數的部分可以修改為:

var: count(0)

if time > 090500 and time < 100000 then begin   //只在介於09:05和10:00的時間計算並警示

    if high = value1 and value3 > 1 and value2 >= 0 and value2 < 0.01 then count += 1;

    if count = 3 then ret = 1;

    end;

 

if getfielddate("Date") <> getfielddate("Date")[1] then count = 0;  //count重置

您開盤會警示的理由很簡單,因為count沒有重置。

只要其在前一天超過3的話,隔日就會警示。

sAAAs 發文於   2022/03/11

了解 謝謝小幫手

發表回覆
Close