選股結果與print不同

  •   283 
  • 最後發表   aRay  2023 二月 12
aRay 發文於   2023/02/03

請教一下小幫手,我試著把選股結果推播到Line用了print指令,但是不知道是那個語法有問題,導致

選股結果與print結果不同,能否麻煩小幫手指點一下呢?謝謝!

 

input: offset(9999,"不用調整,相容用參數");

input: ratio(1, "增加比例%");

var:sameweek(0);

setbarfreq("W");

settotalbar(3);

if getinfo("FilterMode") = 1 then  

sameweek = 0 

else if 

datediff(GetFielddate("收盤價","D"),GetFielddate("收盤價","W")) < 6 

then  sameweek = 1 else  sameweek = 0; 

value1=GetField("大戶持股比例","W",param:=400)[sameweek];

condition1 = close > average(close, 60);

condition2 = close > average(close, 120);

condition3 = volume > 100;

 

if value1 > (value1[1] * (1 + ratio/100)) and condition1 and condition2 and condition3

then 

begin

ret=1;

Print(file("D:\選股\line notify\Strategy\大戶增持"), "選股日期:"+dateToString(date));

Print(file("D:\選股\line notify\Strategy\大戶增持"), "股票名稱:"+SymbolName);

Print(file("D:\選股\line notify\Strategy\大戶增持"), "股票代碼:"+symbol);

Print(file("D:\選股\line notify\Strategy\大戶增持"), "收盤價格:"+numtostr(c, 2));

Print(file("D:\選股\line notify\Strategy\大戶增持"), "增加比例:"+numtostr(Value1-Value1[1], 2));

end;

outputfield(1, Value1-Value1[1],  2, "差異%");

outputfield(2, value1, 2, "大戶比例");

outputfield(3, value1[1], 2, "上周大戶比例");

排序方式: 標準 | 最新
XQ小幫手 發文於   2023/02/07

Hello aRay,

 

如果可以的話,麻煩告知選股執行的日期和有問題的商品讓小幫手確認。

需注意的是,在資料讀取筆數運算時的print也會印出。

由於您設的資料讀取筆數為3筆,所以會印出前兩天符合條件的商品和資訊。

 

另外

if getinfo("FilterMode") = 1 then sameweek = 0 

else if datediff(GetFielddate("收盤價","D"),GetFielddate("收盤價","W")) < 6 then  sameweek = 1 else  sameweek = 0; 

這一段會讓選股、選股回朔 以及 選股回測取到不同的資訊 (sameweek不同),這也有可能導致出來的結果有異。

如果要確保相同的話,小幫手會建議您使用 GetField("大戶持股比例","W",param:=400)[1] 這樣就會去取相同的資料。

aRay 發文於   2023/02/07

謝謝小幫手,現在比較清楚為什麼print出來會不一樣了,但是若是想要選股結果跟print結果一致的話(如附圖)該如何寫呢?

其實我只是想要把每周400大戶持股變化大於1%的個股找出來並print出來輸出到line notify

我有試著用這樣子的想法來寫,可是不能執行…再請小幫手指點!感謝您!

value1=GetField("大戶持股比例","W",param:=400);

value2=GetField("總股東人數");

condition1 = close > average(close, 60);

condition2 = close > average(close, 120);

condition3 = volume > 100;

condition4 = value1 > value1[1];

condition5 = (value1-value1[1])>1;

if condition1 and condition2 and condition3 and condition4 and  condition5

then

begin

ret=1;

Print(file("C:\line notify\Strategy\大戶增持"), "選股日期:"+dateToString(date));

Print(file("C:\line notify\Strategy\大戶增持"), "股票名稱:"+SymbolName);

Print(file("C:\line notify\Strategy\大戶增持"), "股票代碼:"+symbol);

Print(file("C:\line notify\Strategy\大戶增持"), "收盤價格:"+numtostr(c, 2));

Print(file("C:\line notify\Strategy\大戶增持"), "增加比例:"+numtostr(Value1-Value1[1], 2));

end;

 

outputfield(1, Value1-Value1[1],  2, "差異%");

outputfield(2, value1, 2, "大戶比例");

outputfield(3, value1[1], 2, "上周大戶比例");

outputField(4, value2, 0 ,"總股東人數");

outputField(5, value2[1], 0, "上周總股東人數");

outputField(6, value2-value2[1], 0, "增減");

 

 

XQ小幫手 發文於   2023/02/08

 Hello aRay,

 

不能執行的因為是當週的大戶持股比例會在週末的時候才更新。

如果您在當週中使用的話會出錯 (取不到資料),所以小幫手才會建議您使用 GetField("大戶持股比例","W",param:=400)[1]。

 

如果只想要print出最新的資料的話,可以使用 islastbar 來當作條件控制。

aRay 發文於   2023/02/12

了解!謝謝小幫手!

發表回覆
Close