策略雷達中close volume 漲幅是屬日K棒值,若指定頻率改為15分鐘頻率,是否就是15分K棒值?

  •   256 
  • 最後發表   小詹  2023 九月 27
小詹 發文於   2023/09/16

下面是從 警示 中拷貝出來的程式:

condition1=false;

condition2=false;

condition3=false;

if close>100 and

   close<average(close,10)     and 

   volume>average(volume, 5)*3 and

   average(volume, 5)>500     

then condition1=true;  

Value5 = GetQuote("當日漲幅%");

if value5<0

then  condition2=true; 

Value6 = GetField("融券餘額張數");

if value6>0

then  condition3=true; 

if condition1 and condition2 and condition3

then  ret=1;

請問在策略雷達中,若是將指定頻率設定為15分鐘,則程式每15分鐘跑一次,程式中的close  Volume 漲幅 是否就是15分鐘K棒的收盤,成交量與漲幅呢?若指定頻率設定為30或60分鐘是否以此類推?

若我在設定頻率15分鐘,要累計當天成交量超過3000張以上之股票通知我,上面程式應該如何寫?累計當天漲幅超過5%以上之股票通知我上面程式應該如何寫?

排序方式: 標準 | 最新
小詹 發文於   2023/09/16

策略雷達若頻率設定為 日,則是否收盤後才自動跑程式,與收盤後到 選股 手動跑程式 是否意思相同?那麼 日 頻之意義何在?

小詹 發文於   2023/09/18

condition1=false;

condition2=false;

condition3=false;

condition4=false;

variable: n(0);

variable: ToVolume(0);

if close>100 and

   close<500  

then condition1=true;  

 Value1 = GetQuote("當日漲幅%");

if value1>5

then  condition2=true; 

Value2 = GetField("融券餘額張數");

 

if value2>0

then  condition3=true; 

if  Barinterval=15 and barfreq ="Min" then Begin  //適用於15分鐘線

//執行迴圈,執行當日十五分鐘線共18次數

if time = 090000 then begin

for n=1 to 18 begin//以下的陳述(到end;為止),n=1執行一次,n=2執行一次,一直到n=18

if volume[n]<1000

then ToVolume=ToVolume+volume;

end;

end;

//設定警示條件:if.. then ret=1;

if ToVolume>=1000

then  condition4=true; 

if condition1 and condition2 and condition3 and condition4

then  ret=1;

end;

參考 警示 中的程式範例,東拼西湊,以上程式成交量與漲幅不知是否達到累計的效果?

小詹 發文於   2023/09/19

condition1=false;

condition2=false;

condition3=false;

variable: n(0);

variable: ToVolume(0);

variable:yi(0),Toyi(0);

yi=((close-close[1])/close)*100;//close[1]代表前一根收盤價

//指定變數值的計算公式,計算漲跌幅

if close>100 and

   close<500  

then condition1=true;  

if  Barinterval=15 and barfreq ="Min" then Begin  //適用於15分鐘線

//執行迴圈,執行當日十五分鐘線共18次數

if time = 090000 then begin

for n=1 to 18 begin//以下的陳述(到end;為止),n=1執行一次,n=2執行一次,一直到n=18

if volume[n]<1000

Then ToVolume=ToVolume+volume;

end;

end;

//設定警示條件:if.. then ret=1;

if ToVolume>=1000

then  condition2=true; 

if  Barinterval=15 and barfreq ="Min" then Begin  //適用於15分鐘線

//執行迴圈,執行當日十五分鐘線共18次數

if time = 090000 then begin

for n=1 to 18 begin//以下的陳述(到end;為止),n=1執行一次,n=2執行一次,一直到n=18

if yi<5

Then Toyi=Toyi+yi;

end;

end;

//設定警示條件:if.. then ret=1;

if Toyi>=5

then  condition3=true;

if condition1 and condition2 and condition3 

then  ret=1;

end;

end;

 

上面程式,跑看看是否是對的?

 

小詹 發文於   2023/09/20

condition1=false;

condition2=false;

condition3=false;

condition4=false;

variable: n(0);

variable: ToVolume(0);

variable:yi(0),Toyi(0);

 

yi=((close-close[1])/close)*100;//close[1]代表前一根收盤價

//指定變數值的計算公式,計算漲跌幅

 

if close>50 and

   close<500  

then condition1=true;  

  

Value1 = GetField("融券餘額張數","D");

 

if value1>0

then condition2=true;  

  

if  Barinterval=15 and barfreq ="Min" then Begin  //適用於15分鐘線

//執行迴圈,執行當日十五分鐘線共18次數

if time = 133000 then begin

for n=1 to 18 begin//以下的陳述(到end;為止),n=1執行一次,n=2執行一次,一直到n=18

if volume[n]<1000

Then ToVolume=ToVolume+volume;

end;

end;

//設定警示條件:if.. then ret=1;

 

if ToVolume>=1000

then condition3=true; 

 

if  Barinterval=15 and barfreq ="Min" then Begin  //適用於15分鐘線

//執行迴圈,執行當日十五分鐘線共18次數

if time = 133000 then begin

for n=1 to 18 begin//以下的陳述(到end;為止),n=1執行一次,n=2執行一次,一直到n=18

if yi<5

Then Toyi=Toyi+yi;

end;

end;

//設定警示條件:if.. then ret=1;

 

if Toyi>=5

then  condition4=true;

 

if condition1 and condition2 and condition3 and condition4

then  ret=1;

end;

end;

自次修改,精益求精!

 

XQ小幫手 發文於   2023/09/27

 Hello 小詹,

 

小幫手建議您先閱覽教學區的文章,裡面有XS語法的基礎和應用。

 

close, volume 等欄位資訊,在沒有特別指定頻率的情況下 (ex. getfield("Close", "D")) 會是執行頻率的資訊。

所以您設定為60分鐘的話,就會是60分鐘頻率的收盤價和成交量。

 

如果需要跨頻率的話,可以使用 GetField 函數來取得。

舉例來說,getfield("Volume", "D") 就會是日頻率的成交量,如果是在盤中使用,那麼取得的就會是開盤到執行當下的成交量總和。

 

若雷達頻率設定為日的話,要看您是否有勾選逐筆洗價。

有勾選逐筆洗價的話就會是盤中每次洗價時運算,而每次洗價時所使用的頻率會是日頻率。

沒有的話就會和選股類似,要等當根Bar結束後才會運算。

 

至於要確認腳本是否有正確執行,您可以使用 print 函數將相關數值印出確認,看腳本是否有如同您所想的運作。

發表回覆
Close