2013年12月26日 星期四

高檔量縮收黑

   
input:DownPercent(4);  setinputname(1,"當期下跌幅度");
input:Ratio(20);       setinputname(2,"量縮程度%");
input:TieDays(3);      setinputname(3,"量縮持續期數");
input:UpTrendDays(20); setinputname(4,"累計上漲期數");
input:RaisingRatio(20);setinputname(5,"累計上漲幅度");

if Close[TieDays] >  close[UpTrendDays+TieDays-1] * (1+RaisingRatio/100) then
begin
  if Close< high[TieDays] * (1 - DownPercent/100) and
     volume[TieDays] > volume *(1+Ratio/100)
  then ret=1;

end;

階梯式下跌

   
input:TXT("5分鐘線以下"); setinputname(1,"使用限制");

if barfreq<> "Min" or barinterval > 5 then return;

switch (barinterval)
begin
   case 1,2,5:
     if time =091000 and TrueAll(open=high and close=low and close< close[1],10/barinterval) then ret=1;
     break;
   case 3:
     if time =090900 and TrueAll(open=high and close=low and close< close[1],3) then ret=1;
     break;

end;

連續n日開高走低收最低


input:Length(2); setinputname(1,"計算期數");


if Trueall( Open > Close[1]*1.005 and Close<open and close = low , Length) then ret=1;

跳空下跌再破底


//分鐘線
input:Gapratio(1.5);setinputname(1,"跳空下跌百分比%");
input:TXT("僅適用分鐘線"); setinputname(2,"使用限制");

if barfreq<>"Min" then return;

if Close < close[1] and Close < q_DailyOpen then

   if q_DailyOpen < q_RefPrice*(100-Gapratio)/100  then ret=1;

跌破上升趨勢線


input:Length(10); setinputname(1,"上升趨勢計算期數");
input:Angle(30); setinputname(2,"上升趨勢角度");

variable: TrendAngle(0);
variable: TrendAngleDelta(0);

if Close< Close[1] and Close[1] <Close[2] and Close[Length]>0 then begin

linearreg((high/Close[Length]-1)*100,Length,0,value1,TrendAngle,value3,value4);

TrendAngleDelta =TrendAngle-TrendAngle[1];
IF TrendAngleDelta-TrendAngleDelta[1] < -10 and close >Close[Length] THEN RET=1;
 

end;

股價震盪變大且收最低

  
input:Length(5);setinputname(1,"計算震盪幅度的區間期數");
input:BaseLength(20);setinputname(2,"震盪幅度計算區間");
input:Ratio(50);setinputname(3,"震盪放大百分比%");

value1=highest(high,Length)-lowest(low,Length);
value2=average(value1,BaseLength);

if  value1 crosses over value2 *(1+ratio/100) and close=low

then ret=1;

股價跌破走平後的高壓電線


input:Ratio(10); setinputname(1,"高壓電線幅度%");
input:Length(5); setinputname(2,"計算走平期數");

variable: Factor(0);Factor = 100/Close;

if absvalue(linearregslope(avgprice[1]*Factor,Length))<=0.1 and  //走平
   close crosses under ((average(close,30)+average(close,72))/2 )* (1+Ratio*0.01)

then ret=1;

盤中直線下跌


input:SlopeThre(2); setinputname(1,"下降坡度[2~15越大跌越快]");
input:Length(5); setinputname(2,"計算期數");

variable:KBarOfDay(0),tOpen(100); KBarOfDay+=1;
if date<>date[1] then begin KBarOfDay=1; tOpen =Open; end;

if Length < KBarOfDay and currentbar > maxbarsback and
   Linearregslope(Low/tOpen*1000,Length) < SlopeThre*-1 then

ret=1;

海龜出場法則


這個法則是一個順勢交易的策略,也是一個波段策略,通常的作法是在股價突破n週最高價時進場,然後在跌破m週最低價時出場,n及m不一樣,n比較長,m比較短。

這個法則在趨勢成型時可以賺到大波段的錢,但如果是箱型盤整,則來回被巴的機率就頗高,不過拿來作停損停利的賣出點,我個人是覺得還可以,至少是有點道理。

至於n跟m要用幾週? 我個人是覺得看股性,股作活潑的用短一點,股性較牛的用長一點。




   
input:Length(10); setinputname(1,"N週期數");
input:TXT("僅適用周線"); setinputname(2,"使用限制");

if Barfreq<> "W" then Return;

if close < lowest(low[1],Length)//n週最低價

then ret=1;



上一篇我們提到了用跌破N週最低價的方式來決定波段的出場點,這一篇我們接著運用類似的概念,但改成以n週的移動平均線來當進出場的依據。
我們以台積電的13週及20週移動平均線為例子,附圖中,突破長天期均線時進場,跌破短天期均線時出場,紅色向上箭頭是進場點,綠色向下箭頭是出場點,從圖上我們可以很清楚的看到,運用這樣的交易策略,在趨勢形成時可以賺到波段的錢,但在盤整格局中,我們會過度交易而且可能追高殺低。
但至少,在一大段漲勢之後,跌破一個短天期週均線,確實是一個波段賣出的訊號

這樣的訊號跟前一個語法就只差一個函數,把lowest改成average而已,我還是把程式放在下面,等這功能上線後,大家可以copy到語法編輯器中就可以使用了。



input:Length(10); setinputname(1,"近N週期數");
input:TXT("僅適用周線"); setinputname(2,"使用限制");

if Barfreq<> "W" then Return;

if close crosses under average(close,Length)//近n週最低價
then ret=1;



散戶買單比例太高且走低

   
input:ratio(20); setinputname(1,"散戶買單比例%");
input:TXT("須逐筆洗價"); setinputname(2,"使用限制");

//單筆外盤成交值低於五十萬元稱為散單 //內外盤:內盤-1 外盤1
variable: intrabarpersist ACount(0);
variable: intrabarpersist TimeStamp(0);

if barfreq ="Min" and currentdate = date then //分鐘線在今天時
begin
  TimeStamp =currenttime;
  if TimeStamp = TimeStamp[1] then  ACount=0;
  if TimeStamp[1] <= time  then // 盤中開啟 or Bar第一個進價
  begin
      if  q_BidAskFlag > 0 and q_TickVolume *Close <=500 then
            ACount = q_TickVolume *Close
        else
            ACount=0;
  end
  else
  begin
     if  q_BidAskFlag > 0 and q_TickVolume *Close <=500 then ACount+= q_TickVolume *Close;
  end;
  if ACount >= Ratio/100 * volume*close and 
     Close < q_RefPrice*0.985 and q_DailyHigh < q_RefPrice*1.005 then ret=1;
end;

if barfreq ="D" then
begin
  if  Date <> currentdate then Acount=0;
  if  q_BidAskFlag > 0 and q_TickVolume *Close <=500 then ACount+= q_TickVolume *Close;
  if ACount >= Ratio/100 * q_DailyVolume * q_AvgPrice and
     Close < q_RefPrice*0.985 and q_DailyHigh < q_RefPrice*1.005 then ret=1;

end;

投信外資都賣超


input:TXT("僅適用日線"); setinputname(1,"使用限制");

if Barfreq <> "D" then return;

if Open < Close[1] and  Close < Close[1] and
   GetField("外資買賣超")[1]<0 and GetField("投信買賣超")[1]<0

then ret=1;

巨量長黑


input:Amount(10000); setinputname(1,"依頻率設定巨量門檻");

if open > Close * 1.025//實體
and close[1] > Close * 1.035 //較前一日大跌
and volume >=amount

then ret=1;

天量後價量未再創新高

   
input:XLength(60); setinputname(1,"長期大量計算期數");
input:Length(3); setinputname(2,"自高點回檔天數");
input:TXT("建議使用日線"); setinputname(3,"使用說明");

variable: PriceHighBar(0),VolumeHighBar(0);

extremes(high,Length,1,value1,PriceHighBar);
extremes(volume,XLength,1,value1,VolumeHighBar);

if (PriceHighBar =Length-1) and VolumeHighBar=Length-1  then

ret=1;

天價留上影線後未開高


當我們手中持股創下波段最高價之後,我們通常都很高興,
但往往高興之餘就降低了危機意識,突破整理後的天價是該
高興,但有些天價是出現在利多出盡的那一天,這種天價就
要很小心,因為當別人貪婪時,可能就是我們得見好就收的
時候。這樣的股票,我們必須留意兩件事,第一件是天價後
與收盤價的價差幅度,第二件是隔天開盤的表現。如果伴隨利多出現的天價當天有明顯的上影線,隔天又開平盤以下,那就代表買盤已被伺機要賣股票的賣壓給消化殆盡,多殺多的可能性會很高,這時候就要很小心了。

我們可以透過XS的語法,把上述的情況寫成腳本如下:


input:Length(20); setinputname(1,"設定波段天數");
input:P1(2); setinputname(2,"設定高檔壓回百分比");
input:P2(0.5); setinputname(3,"當日開高基準百分比");
input:P3(0.5); setinputname(4,"上影線佔價格幅度%");
input:TXT("建議使用日線"); setinputname(5,"使用說明");

if  open - close[1] <P2/100*close[1]  and
    high[1]=highest(high,Length)  and
    (high[1]-close[1])>= P1/100 *close[1] and
    high[1] > maxlist(open[1], close[1]) *(1+P3/100)

then  ret=1;



多日價量背離





以前老市場常說,會買股票的徒弟,會賣股票的才是師傅。這些年,我也算認識了不少人,明牌之類的,多少會聽到一些,長期下來,我發現,我可以存活下來,是因為我那如野獸般可以聞到危險的嗅覺,一覺得不對勁,我就殺光持股,雖然常常砍早了,但至少躲過了每一次的大回檔。

我一直覺得挑股票我不見得多厲害,但砍股票倒是蠻有自信,所以這次的語法交易平台一完工,我就先把我會什麼會砍股票的想法寫成警示腳本,大家一起來培養如野獸般的嗅覺。

 向大家報告的是連續多日價量背離。


腳本如下:

input:Length(5); setinputname(1,"計算期數");
input:times(3);setinputname(2,"價量背離次數");
input:TXT("建議使用日線"); setinputname(3,"使用說明");

variable:count(0);

count = CountIf(close > close[1] and volume < volume[1], Length);

if count > times then

ret = 1;


當我手中的持股出現連續幾天股價收紅,但成交量一路萎縮,而且沒有停資停券,大盤量也沒有大縮,類股資金是淨留入時,我就會很小心
。因為這代表的是沒有人追價,這種股票整理或拉回的機率比較高,特別是如果先前已大漲一段,那就是多頭要休息的訊號,如果是上漲沒有量,下跌量就增加,那就更要小心了。

這個訊號準確度沒有很高,因為量縮的原因很多,有時候純粹是因為市場出現不確定因素,或是資金被特定族群或個股吸走,在應用上,只有在找不出合理的價量背離解釋時,才需要砍股票,因為莫名其妙的背離,代表的才是危險的訊號,這一點,得先跟大家說個明白。





分鐘線九連黑

   
Input: Length(9); SetInputName(1, "連續筆數");

if Barfreq ="Min" then

   if trueall(close < open,Length) then ret=1;

主力出貨

主力出貨通常有幾個特徵(用在10分鐘線)
1.下跌時幅度比上漲時大,也就是黑K棒較多,紅K棒較少。
2.下跌時有量,上漲時量縮
3.下跌時走勢較陡。也就是黑K棒較長,紅K棒較短

特別是如果把大盤的走勢考慮進出之後,這檔股票走的特別的弱勢,而且又是一大段的漲勢之後,那就很有可能是主力在出貨。

另外,如何分辨主力出貨還是主力洗盤?
我個人的經驗是,主力洗盤是通常走逆勢,大盤漲時他故意壓著讓散戶受不了換股,尾盤再打下去讓散戶吐血,出貨時則是順勢賣,盤中又賣又拉,尾盤前先殺一趟,尾盤再拉,隔天又開高繼續出。


下面是XScript計算下跌量與上漲量比的語法



input:RatioThre(1.5); setinputname(1,"下跌量上漲量比");

variable: upvolume(0);//累計上漲量
variable: downvolume(0);//累計下跌量
variable: uprange(0);//累計上漲值
variable: downrange(0);//累計下跌值
variable: DUratio(0);//下跌量上漲量比
if date[1] <> date then
begin
      downvolume  =0; upvolume =0;
      uprange =0; downrange=0;
      if close > open then 
        begin
          upvolume = volume;
          uprange = close -open;  
        end
      else
      if close < open then 
        begin
          downvolume = volume; 
          downrange = open -close;
        end
      else
      if close < close[1] then 
        begin
          downvolume = volume; 
          downrange = close[1] -close;
        end
      else
      if close > close[1] then 
        begin
          upvolume = volume;
          uprange = close -close[1];
        end;
end;//如果前一個跟Bar跟目前的bar日期不同 今天第一根起算

if date[1] = date then  //還在同一天
begin
      if close > close[1] then 
        begin
          upvolume += volume;
          uprange += close -close[1];  
        end
      else
      if close < close[1] then 
        begin
          downvolume += volume; 
          downrange += close[1] -close;
        end;
 if upvolume > 0 then DUratio = downvolume/upvolume else DUratio=1;
end;


if DUratio crosses over RatioThre and uprange crosses under downrange then ret=1;






一黑破n紅


input:Length(3); setinputname(1,"計算期數");

if high=highest(high[1],Length) and close<lowest(low[1],Length)

then ret=1;

一舉跌破多根均線

一根黑棒如果可以一次貫穿三條均線,代表這三個期別的的持股者都被套牢,當持股踫到這樣的情況,如果這根黑棒又是帶量且收最低,那就是機率很高的反轉訊號。
input: shortlength(5); setinputname(1,"短期均線期數");
input: midlength(10);  setinputname(2,"中期均線期數");
input: Longlength(20); setinputname(3,"長期均線期數");

variable: shortaverage(0);
variable: midaverage(0);
variable: Longaverage(0);


shortaverage=Average(close,shortlength);
midaverage=Average(close,midlength) ;
Longaverage = Average(close,Longlength);

if close  crosses under  shortaverage and
   close  crosses under  midlength and
   close  crosses under  Longaverage
then ret=1;  

以下圖為例,當三條均線糾結在一起,代表的是短中長期的平均持股成本都在這附近,當股價跌破時,代表短中長期持股者都在同一天被套牢,這時候會造成大量的持股信心鬆動,股價再創低點的機率大增。