前幾天,同事問說能不能把怪傑33的抄底指標在XQ量化平台寫成指標給大家參考,我試著寫了一個如下,先聲明,這只是個Sample,目的是讓大家可以盡情的用這個Sample套上自己中意的抄底指標,然後應用在K線上,附圖是這個Sample跑在幾檔藍籌股上的圖,我寫的腳本如下:
if close*1.05<close[20] then begin //20個交易日跌超過5% if barfreq <> "D" then raiseruntimeerror("不支援此頻率"); //只有在日線適用 condition1=false; condition2=false; condition3=false; condition4=false; condition5=false; condition6=false; condition7=false; condition8=false; condition9=false; condition10=false; switch(close) begin case >150: value5=low*0.9; case <50 : value5=low*0.98; default: value5=low*0.95; end; //用value5來代表在K線上標註的進場點,讓他顯示在K線的下方 //==========法說會前大股東買超================ input: N1(5, "連續 N1 日成交量 > X1 張,N1"); input: X1(500, "連續 N1 日成交量 > X1 張,X1"); input: N2(14, "N2 日內有法說會,N1"); input: N3(3, "N3 日內主力買超數量總計佔成交量 X2 %,N3"); input: X3(2, "N3 日內主力買超數量總計佔成交量 X2 %,X2"); // 連續 N1 日成交量 > X1 張 Condition11 = trueall(volume > X1, N1); // N2 日內有法說會 value1 = DateDiff(GetField("法說會日期"), Date); Condition12 = 0 < value1 and value1 < N2; // N3 日內主力買超數量總計佔成交量 X3 % Condition13 = summation(GetField("主力買賣超張數","D"), N3) > summation(volume, N3) * X3 / 100; // 關鍵券商買超 Condition14 = GetField("關鍵券商買賣超張數","D") > 0; if condition11 and condition12 and condition13 and condition14 then condition1=true; if condition1 then plot1(value5," 法說會前公司派買超"); //============股價接近主力成本線==================== value1=GetField("主力買張"); value2=(o+h+l+c)/4; value3=value1*value2;//做多金額 if summation(value1,40)<>0 then value4=summation(value3,40)/summation(value1,40); //金額除以張數等於成本 if absValue(value4/close-1)<0.04 then condition2=true; if condition2 then plot2(value5*0.99,"股價接近主力成本線"); //===========近兩日主力買超============== if trueall(GetField("主力買賣超張數","D")>500,2) then condition3=true; if condition3 then plot3(value5*0.98,"近兩日主力買超"); //===========資金重新回到該類股================ value6=GetField("成交金額","D"); value7=GetSymbolField("tse.tw","成交金額","D"); if value6<>0 then value8=value6/value7*100; value9=average(value8,20); value10=value8/value9; if value10>1.1 then condition4=true; if condition4=true then plot4(value5*0.97,"籌碼收集"); //===========法人同步買超==================== variable: v1(0),v2(0),v3(0),c1(0); v1=GetField("外資買賣超"); v2=GetField("投信買賣超"); v3=GetField("自營商買賣超"); c1= barslast(minlist2(v1,v2,v3)>100); if c1=0 and c1[1]>10 then condition5=true; if condition5=true then plot5(value5*0.96,"法人同步買超"); //========DIF-MACD 翻正============= input: _TEXT3("===============","MACD參數"); input: FastLength(12,"DIF短天數"), SlowLength(26, "DIF長天數"), MACDLength(9, "MACD天數"); variable: difValue(0), macdValue(0), oscValue(0); MACD(weightedclose(), FastLength, SlowLength,MACDLength, difValue, macdValue, oscValue); variable:c6(0); c6=barslast(oscValue Crosses Above 0); if c6=0 and c6[1]>10 then condition6=true; if condition6 then plot6(value5*0.95,"DIF-MACD 翻正"); //========開盤委買遞增====================== var:o1(0); o1=getField("開盤委買", "D"); if o1>o1[1] and o1[1]>o1[2] then condition7=true; if condition7 then plot7(value5*0.94,"開盤委買遞增"); //=========總成交次數明顯增加================ variable: t1(0),mat1(0),c8(0); t1=GetField("總成交次數","D"); mat1=average(t1,20)*1.1; c8=barslast(t1 crosses over mat1 and close>close[1]); if c8=0 and c8[1]>20 then condition8=true; if condition8 then plot8(value5*0.93,"成交次數明顯增加"); //=========連兩日股價表現優於大盤================== variable:s1(0),c9(0); s1=GetField("強弱指標","D"); c9=barslast(trueall(s1>0,2)); if c9=0 and c9[1]>20 then condition9=true; if condition9 then plot9(value5*0.92,"連兩日股價表現優於大盤"); //============股價跌回BBand下緣後回升================ input:length(20); variable:up1(0),down1(0),mid1(0),bbandwidth(0); up1 = bollingerband(Close, Length, 1); down1 = bollingerband(Close, Length, -1 ); mid1 = (up1 + down1) / 2; if absValue(close/down1-1)<0.03 and close>close[1] and down1>down1[1] and down1[1]>down1[2] then condition10=true; if condition10 then plot10(value5*0.91,"股價跌回BBand下緣後回升"); end;
這陣子行情不好,寫抄底腳本就怕接到下跌中的刀子,大家可以留意一下,最好是有多個不同的抄底指標都出訊號會比較safe一點
另外還是要再聲明一下,這只是樣本,真的拿去用了,買股票套牢了別去告我,小弟只是拋磚引玉,期待各位大大拿來改出千古一指標的
最後祝大家操作順利
至於要在K線圖上要如何呈現那個三角形的標誌,可以參考以下這一篇 ➤https://pse.is/3m5sbj
===
● XQ【盤中量化交易模組】($1,000) 七大功能,購買就送【台股進階(原價$300)+小道瓊行情(延遲)】完整介紹 ➤https://pse.is/46xbpu
● 首次訂閱享7天鑑賞期,首次購買輸入官方優惠碼「@XQ8899」,首月可折抵模組費用$100!
● XQ量化交易平台 立即了解 ➤https://utm.to/3lfuyn