2013年12月5日 星期四

兩根K棒的多空力道祕密 (程式碼)

EasyTrader ArtNo 067
每天的K棒型態都有其涵意,能夠代表當日多空力道的展現,所以看盤的第一項工作就是觀察K棒為多方型態還是空方型態。

多方型態的K棒分為:

1、下影線長於實體部分,實體部分越短越好,不論當日為紅K棒或黑K棒,都視為多方力道勝出,通常出現在下跌趨勢中,代表多方支撐力道出現,有機會止跌上漲。
2、中長紅K棒,上影線非常短甚至沒有上影線,這種K棒型態代表多方強勢攻擊,空方幾乎沒有抵抗力道,可視為多方攻擊K棒。

空方型態K棒分為:
1、上影線長於實體部分,實體部分越短越好,不論當日為紅K棒或黑K棒,都視為空方力道勝出,通常出現在上漲趨勢中,代表空方賣壓力道出現,可視為止漲下跌。
2、中長黑K棒,下影線非常短甚至沒有下影線,這種K棒型態代表空方強勢攻擊,多方幾乎沒有抵抗力道,可視為空方攻擊K棒。

根據前述說明發展出來的多空力道指標圖


K棒多空力道指標程式碼
inputs: Avg(20), Smoothing(5),HighBand(20),LowBand(20) ;
variables: BullPower(0), BearPower(0),ShowPower(0) ;

{Bull Power}
If Close < Open then
   If Close[1] < Open then BullPower = MaxList(High - Close[1], Close - Low )
      else BullPower = MaxList(High - Open, Close - Low)
else  If ( Close > Open ) then
             If Close[1] > Open then BullPower = High - Low
                  else  BullPower = MaxList(Open - Close[1], High - Low )
else  If ( High - Close > Close - Low ) then
             If Close[1]< Open then   BullPower = MaxList( High - Close[1], Close - Low )
                 else  BullPower = High - Open
else   If  High - Close < Close - Low then
            If Close[1] > Open then BullPower = High - Low
                else  BullPower = MaxList(Open - Close[1],High - Low )
else   If Close[1] > O then BullPower = MaxList( High - Open,Close - Low )
          else  If  Close[1] < O then BullPower = MaxList( Open - Close[1], High - Low )
else  BullPower = High - Low ;

If Close < Open then
    If Close[1]> Open then BearPower = MaxList(Close[1]- Open,High - Low )
       else BearPower = High - Low
else If Close > Open then
    If Close[1] > Open then BearPower = Maxlist( Close[1] - Low, High - Close)
        else  BearPower = Maxlist(Open - Low, High - Close )
else If High - Close > Close - Low then
     If Close[1] > Open then BearPower = MaxList(Close[1]-Open, High - Low )
         else BearPower = High - Low
else  If  High - Close < Close - Low then
            If Close[1]> Open then BearPower = MaxList(Close[1]-Low,High - Close )
                else  BearPower = Open - Low
else  If Close[1]> Open then BearPower = MaxList(Close[1]-Open, High - Low )
            else If Close[1]<O then BearPower = MaxList(Open - Low,High - Close)
else  BearPower = High - Low ;

ShowPower = Xaverage( XAverage( BullPower, Avg ) - XAverage( BearPower, Avg ),Smoothing ) ;
plot1(ShowPower,"ShowPower",iff(ShowPower >= 0 , Magenta,Cyan),Black,1);
Plot2(HighBand,"HighBand",Yellow) ;
Plot3(-LowBand,"LowBand",White) ;
Plot4(XAverage(ShowPower,5),"Xavg",LightGray,Black,1) ;

根據指標作成的策略核心

if ShowPower Cross over UpBand then Buy ("Bull") next bar at highest(High,3) stop {Market} ;
if ShowPower Cross under -DnBand then Sell ("Bear") next bar at Lowest(Low,3) stop {Market} ;
if Mp > 0 and ShowPower Cross over HighBand then Sell {Exitlong} ("Bullexit") next bar at Market ;if MP < 0 and ShowPower Cross under -LowBand then Buy {ExitShort} ("Bearexit") next bar at Market ;

搭配不同的濾網
1. 平盤上作多: Close > OpenD(0) and OpenD(0) > CloseD(1)
2. 平盤下作空: Close < OpenD(0) and OpenD(0) < CloseD(1)
3. 昨日高低點範圍 HighD(1)-LowD(1)


買賣點
1. 近 N 根K棒高點買進 Buy next bar at Highest(High ,3 {Avg} ) stop { Market};
2..近 N 根K棒低點賣出 Sell next bar at Lowest(Low ,3 {Avg}) stop { Market};
3. 近 N 日K棒高點買進 Buy next bar at MaxList(HighD(1),HighD(2),HighD(3)) stop
4..近 N 日K棒低點賣出 Sell next bar at MinList(LowD(1),LowD(2),LowD(3)) stop


不同組合篩選出來的 5組績效,讀者可以仿前幾篇方式作練習




MagicQS021

沒有留言:

張貼留言