大家好,

分享使用警示範例腳本撰寫創盤中新高價,

 

撰寫方式說明:

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

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

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

3. 使用 getfield 函數,跨日頻率取今日最高價,並用 value1 變數設立旗標的方式儲存當日最高價,以便撰寫創盤中新高。

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

 

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

 

 

警示腳本範例如下:

//創盤中新高價
if barfreq <> "tick" then raiseruntimeerror("此腳本僅適用TIck頻率!");
variable:history_high(0);
if getinfo("isrealtime") <> 1 then return;

if value1 =0 then 
    begin
        history_high = GetField("最高價","D");
        value1 = 1;
    end;

if high > history_high then
    begin   
        ret = 1;
        history_high = high;
    end;

print(date,time,value1,GetField("最高價","D"),high,history_high);

 

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