大家好,
分享使用選股範例腳本撰寫以下四個條件所組成的選股策略:
1.收盤價>MA20 and 收盤價<MA20*1.1
2.收盤價過兩日高
3.量>1000
4.收盤價 距離布林低軌 與中軌間(布林通道期數:22、下通道標準差倍數:2)
撰寫方式大致說明:
1. 使用 時間序列 方式,搭配 highest 函數,撰寫收盤價過前兩日高的條件,
2. 使用 OutputField 函數 檢驗計算數值是否正確( 請參考 選股欄位放大鏡:談OutputField )
選股範例策略執行完的結果畫面供參考:

選股範例腳本程式碼如下:
input:MA_length(20,"均線期數"),H_length(2,"N日高"),Target_Volume(1000,"門檻成交量"),Bol_Length(22,"布林期數"),LowerBand(2,"通道下緣"); value1 = average(close,MA_length); value2 = highest(high[1],H_length); value3 = bollingerband(Close, Bol_Length, -1 * LowerBand); value4 = average(close,Bol_Length); if close > value1 and close < value1 * 1.1 and close > value2 and volume > Target_Volume and close > value3 and close < value4 then ret = 1; outputfield1(volume,"volume"); outputfield2(value1,"MA"); outputfield3(value2,"兩日高"); outputfield4(value3,"布林下通道"); outputfield5(value4,"布林中軌");
以上供參考,有問題歡迎詢問。