私房交易策略之強勢股整理結束

By | 2015-10-15

以前寫情書的時候,我們常說: 妳的過去我來不及參與,但妳的未來一定有我。

作為一個操作者,我們對那些來不及上車的強勢股,也往往有這樣的心情,

這樣的心情,如果用波浪理論來解釋,那就是在初昇段來不及參與之後,希望在主昇段發動前夕,來得及坐上車。

101701

為了尋找這一類的股票,我試著寫一個腳本,這個腳本有三個步驟

1.尋找特定日期以來漲幅最大,走勢最強的股票

2.這樣的股票,從這段時間以來的最高點到前一日的收盤,已修正一定的幅度

3.今天盤中該個股明顯走強。

在要寫這個腳本時,首先得先找出某特定日到最新的收盤價,一共是幾根Bar。

公司同仁寫了一個函數來做這件事,他把這個函數稱之為

getbaroffset

 

這個函數的腳本如下:

Input: target(numeric);

if barfreq <> "D" AND barfreq <> "W" AND barfreq <> "M" then raiseruntimeerror("只支援日/週/月頻率");

variable: i(0);
variable: target_ym(0), date_ym(0);

if barfreq = "D" then
begin
 if target >= date then
 begin
 GetBarOffset = 0;
 return;
 end;
 i = 1;
 GetBarOffset = 1;
 while i < currentbar
 begin
 if date[i] <= target then return;
 i = i + 1; 
 GetBarOffset = GetBarOffset + 1;
 end;
end;

if barfreq = "W" then
begin 
 target_ym = year(target) * 100 + weekofyear(target);
 if dayofweek(target) = 0 then target_ym = target_ym - 1;
 
 GetBarOffset = 0;
 i = 0;
 while i < currentbar
 begin
 date_ym = year(date[i]) * 100 + weekofyear(date[i]);
 if dayofweek(date[i]) = 0 then date_ym = date_ym - 1;
 
 if date_ym <= target_ym then return;
 i = i + 1;
 GetBarOffset = GetBarOffset + 1;
 end; 
end;

if barfreq = "M" then
begin
 target_ym = year(target) * 100 + month(target);
 
 GetBarOffset = 0;
 i = 0;
 while i < currentbar
 begin
 date_ym = year(date[i]) * 100 + month(date[i]);
 
 if date_ym <= target_ym then return;
 i = i + 1;
 GetBarOffset = GetBarOffset + 1;
 end; 
end;

這個函數是只要輸入一個日期,就會回傳從現在到該特定日期共隔了幾根Bar。

如果今天是2015年10月15日,那如果我們寫value1=getbaroffset(20151014);

那代表是前一根bar,所以value1=1;

有了這個函數,我就來寫出上面所提到的這個腳本

input: stardate(20150824);
input:ratio(30);
input:ratio1(7);
input:ratio2(2);
setinputname(1,"輸入上漲起始日");
setinputname(2,"輸入上漲最低幅度");
setinputname(3,"輸入最小拉回幅度");
setinputname(4,"今日最低漲幅");
value1=getbaroffset(stardate);//找出輸入的日期是在第幾根bar
value2=highest(high[1],value1+1);//找出這一波的最高點

condition1=false;
condition2=false;

if value2>=close[value1]*(1+ratio/100)//計算波段漲幅有沒有符合要求
then condition1=true;

if value2>=close[1]*(1+ratio1/100)//計算拉回的幅度夠不夠要求
then condition2=true;

if nthhighestbar(1,high,10)>=5//從最高點到今天超過五根bar
then begin
if condition1 and condition2 and close>=close[1]*(1+ratio2/100)
then ret=1;
end;

在解釋這個腳本之前,我們先來看一下大盤最近的走勢

101702

 

所以我上面寫的這個腳本,就是找出符合下面四個條件的股票

1.從8/24日以來,到最高點漲幅超過30%的股票

2.從最高點到前一個交易日的低點修正幅度超過7%

3.今天收盤比前一天收盤漲超過2%

4.從高點拉回整理超過五天。

這樣的腳本要尋找的,就是整理結束後的強勢股。

下面這張圖就是這個腳本今天跑出來的股票

101501

 

當然不是每檔股票都會在初昇段之後就一定有主昇段,也不見得每檔股票都是休息了幾天後就開始再往上攻,不過這個策略的好處是,對於那些從特定日期以來走勢很強的股票,一旦整理結束,我們在第一時間就會收到電腦的通知,這樣的好處是我不必一直盯著強勢股等拉回結束。

這個腳本可以名列我的私房腳本第二名,介紹給大家,至於日期及漲幅,拉回幅度,這些參數就請大家自己調整囉!