大家好,

分享使用警示範例腳本撰寫盤中成交張數>5日均量/100的策略,

 

撰寫方式說明:

1. 使用以下程式碼,避免策略雷達指定頻率設錯。

if barfreq <> "tick" then raiseruntimeerror("此腳本僅適用TIck頻率!");

2. 使用 getinfo 函數,判斷在今日即時盤中時間,才會執行腳本。

3. 使用 getfield 函數,跨日頻率取日成交量,以便計算5日均量。

4. 使用 print 語法,以便檢驗數值是否正確( 可查看 如何運用Print指令來抓程式的臭蟲 操作說明 )

 

策略雷達內容設定畫面參考:

 

警示腳本範例如下:

//盤中成交張數>5日均量/100
if barfreq <> "tick" then raiseruntimeerror("此腳本僅適用TIck頻率!");
input:Length(5,"均量天期");
if getinfo("isrealtime") <> 1 then return;

value1 = average(getfield("成交量","D"),Length)/100;
if volume > value1 then ret = 1;

print(date,time,volume,value1);

 

以上,供大家參考,有問題歡迎詢問。