為何我的腳本策略雷達只能部分執行

  •   244 
  • 最後發表   KHJBSNET  2021 八月 23
KHJBSNET 發文於   2021/08/16

進場腳本:

input: averageVolume(1000);

variable:rsv_d(0), KK(0), dd(0);

stochastic(40,3,3, rsv_d, KK, dd); 

value1 = average(close,60);

value2 = LinearRegSlope(value1,60);

Value3 = q_Last;//成交價

value4 = average(GetField("Volume", "D")[1], 5);//"5日均量"

condition1 = KK < 40 and KK[1] >=40 and KK[2] >=40 and KK[3] >=40;

condition1 = close < value1;

condition2 = close[1] >= 20 and value4 >= averageVolume;

condition3 = close < close[1];

condition4 = value2 > 0;

condition5 = value2 < value2[1] ;

condition6 = close cross above average(close,20);

condition7 = KK cross above 20;

//進場

variable:byin(false),byprice(0);

if byin=false and condition1 and condition2 and condition3 and condition4 and condition5

then

   begin

   byin=true;

   ret=1;

   byprice=close;

   end;

{//出場

if byin=true and condition6 or condition7;

   begin

   byin=false;

   ret=1;

   end;

//尾盤出場

if byin=true and time > 132400 and volume > 0 then

   begin

   byin=false;

   ret=1;

   end;}

   

print(time,rsv_d, KK, dd,byin,byprice,condition1,condition2,condition3,condition4,condition5);

 

出場腳本:

input: averageVolume(1000);

variable:rsv_d(0), KK(0), dd(0); //宣告3個參數

stochastic(40,3,3, rsv_d, KK, dd); //XQ內建寫好的KD函?==>呼叫他

value1 = average(close,60);

value2 = LinearRegSlope(value1,60);

Value3 = q_Last;//成交價

value4 = average(GetField("Volume", "D")[1], 5);//"5日均量"

condition1 = KK < 40 and KK[1] >=40 and KK[2] >=40 and KK[3] >=40;

condition1 = close < value1;

condition2 = close[1] >= 20 and value4 >= averageVolume;

condition3 = close < close[1];

condition4 = value2 > 0;

condition5 = value2 < value2[1] ;

condition6 = close cross above average(close,20);

condition7 = KK cross above 20;

//進場

variable:byin(false),byprice(0);

if byin=false and condition1 and condition2 and condition3 and condition4 and condition5

then

   begin

   byin=true;

   byprice=close;

   end;

//出場

if byin=true and condition6 or condition7 then

   begin

   byin=false;

   ret=1;

   end;

//尾盤出場

if byin=true and time > 132400 and volume > 0 then

   begin

   byin=false;

   ret=1;

   end;

   

print(time,rsv_d, KK, dd,byin,byprice,condition1,condition2,condition3,condition4,condition5);

煩請解答!

排序方式: 標準 | 最新
XQ小幫手 發文於   2021/08/18

Hello KHJBSNET,

 

小幫手看腳本的部分應該是沒有問題。

測試看起來也沒有問題。

需要麻煩您提供 警示雷達匯出檔、錯誤訊息(參考附圖)、以及XQ Log來檢驗。

Log資料夾(預設路徑:C:\SysJust\XQLite\LOG)直接壓縮後提供即可。

您可以直接將檔案上傳,如果檔案過大的話也可以Mail至客服信箱 XQservice@XQ.com.tw且附上 討論文章連結網址(小幫手才能盡早處理)。

感謝。

 

需注意警示腳本只能進場或是出場,沒有辦法將進出場寫在同一個腳本內一起執行。

您可以考慮使用交易腳本就不會有如此限制。

附加文件

XQ小幫手 發文於   2021/08/23

Hello KHJBSNET,

 

經工程師檢驗,您的問題出現在有些商品長度不足而發生錯誤,所以導致部分執行。

另外需注意Log紀錄中有次啟動的資料讀取筆數為0,因此會造成商品所需長度不足而發生錯誤。

這有可能是因為您將開始日期設為當天所導致。

發表回覆
Close