2013年9月26日 星期四

金融商品交易 觀盤篇 變身的K棒(I)

EasyTrader - ArtNo 004
人的心理變化是很奇妙的, 在金融商品交易中 , 不論多空都希望看到K棒的顏色是順著自己操作的方向 , 但是在多空拉距爭戰的過程, 即使是趨勢盤也會紅綠相隔 , 更遑論是多空雙巴的盤整盤 , 因此常無法對自己的作單有信心 ,很容易就被上沖下洗的抬出場 ,當然有經驗的高手在各種盤勢變化中總是能找到利基. 對於一般觀盤交易, 如何在多變的盤勢中,不讓自己輕易被洗盤出場 , 我們在此介紹可以讓 K棒變身的內建語法 PlotPaintBar 來幫忙

PlotPaintBar(High, Low, Open, Close,” PlotName”,FGcolor , BGColor , PlotWidth) ;

High = K棒最高價 , Low = K棒最低價 , Open = K棒開盤價 , Close = K棒收盤價
PlotName = K 棒名稱 ( 可省略 )
FGcolor = 前景色 , BGcolor = 背景色 , PlotWidth = K 棒寬度
也可簡化為 PlotPaintBar(High, Low,” PlotName”) ;

現在來看看前面幾篇文章的箱型指標與依據不同條件變身後的 K 棒組合後的模樣

由於TS2000i 的限制 , 因此程式碼一樣分成 2個, 一個作 High/Low 細線段 , 一個作 Open/Close 粗體段來模擬K棒 (若讀者使用的是高階版本的交易軟體 ,可將程式碼整合為一)

程式碼

{ 此段程式作 High/Low }
input: Type(1), Price(Close),Len(5), OverBought(70),OverSold(30);

{1.Day Open , 2.Yesterday Close, 3. (H+L)/2 , 4.Xaverage line 5. Macd , 6. Macd Diff , 7. RSI ,8 SlowK}

Vars: Gate(Close); { Reference price for Paintbar }
if Type = 1 then
    if DataCompression < 2 then Gate = OpenD(0) else Gate = Open ;

if Type = 2 then
   if DataCompression < 2 then Gate = CloseD(1) else Gate = Close[1] ;

if Type = 3 then
   if DataCompression < 2 then Gate = (HighD(0)+LowD(0))/2 else Gate = (High+Low)/2 ;

if Type = 4 then Gate = Xaverage(Price,Len) ;

if Type = 5 then Gate = MACD(Price,12,26) ;

if Type = 6 then Begin
   Value1 = MACD(Price, 12, 26);
   Value2 = XAverage(Value1, 9);
   Gate = Value1 - Value2 ;
end;

if Type = 7 then Gate = RSI(Price,Len) ;

if Type = 8 then Gate = SlowK(Len) ;

if Type <= 4 then
   if Close >= Gate then PlotPaintBar(High,Low,"",Magenta,Black,0)
        else PlotPaintBar(High,Low,"",Cyan,Black,0) ;

if Type >= 5 and Type <= 6 then
   if Gate >= 0 then PlotPaintBar(High,Low,"",Magenta,Black,0)
       else PlotPaintBar(High,Low,"",Cyan,Black,0) ;

if Type >= 7 and Type <= 8 then
   if Gate >= OverBought then PlotPaintBar(High,Low,"",Magenta,Black,0)
       else if Gate <= OverSold then PlotPaintBar(High,Low,"",Cyan,Black,0)
           else PlotPaintBar(High,Low,"",Yellow,Black,0);


{ 此段程式作 Open/Close }
input: Type(1), Price(Close),Len(5), OverBought(70),OverSold(30);

{1.Day Open , 2.Yesterday Close, 3. (H+L)/2 , 4.Xaverage line 5. Macd , 6. Macd Diff , 7. RSI ,8 SlowK}

Vars: Gate(Close); { Reference price for Paintbar }

if Type = 1 then
    if DataCompression < 2 then Gate = OpenD(0) else Gate = Open ;

if Type = 2 then
    if DataCompression < 2 then Gate = CloseD(1) else Gate = Close[1] ;

if Type = 3 then
    if DataCompression < 2 then Gate = (HighD(0)+LowD(0))/2 else Gate = (High+Low)/2 ;

if Type = 4 then Gate = Xaverage(Price,Len) ;

if Type = 5 then Gate = MACD(Price,12,26) ;

if Type = 6 then Begin
    Value1 = MACD(Price, 12, 26);
    Value2 = XAverage(Value1, 9);
    Gate = Value1 - Value2 ;
end;

if Type = 7 then Gate = RSI(Price,Len) ;

if Type = 8 then Gate = SlowK(Len) ;

if Type <= 4 then
    if Close >= Gate then PlotPaintBar(Open,Close,"",Magenta,Black,2)
        else PlotPaintBar(Open,Close,"",Cyan,Black,2) ;

if Type >= 5 and Type <= 6 then
    if Gate >= 0 then PlotPaintBar(Open,Close,"",Magenta,Black,2)
        else PlotPaintBar(Open,Close,"",Cyan,Black,2) ;

if Type >= 7 and Type <= 8 then
    if Gate >= OverBought then PlotPaintBar(Open,Close,"",Magenta,Black,2)
        else if Gate <= OverSold then PlotPaintBar(Open,Close,"",Cyan,Black,2)
            else PlotPaintBar(Open,Close,"",Yellow,Black,2);

1. 收盤價在當日開盤價之上 ,為多方顏色(桃紅) , 收盤價在當日開盤價之下 ,為空方顏色(淺藍)




2. 收盤價在昨日收盤價之上 ,為多方顏色(桃紅) , 收盤價在昨日收盤價之下 ,為空方顏色(淺藍)



3. 收盤價在當日中關價之上 ,為多方顏色(桃紅) , 收盤價在當日中關價之下 ,為空方顏色(淺藍)



4. 收盤價在指數平均線之上 ,為多方顏色(桃紅) , 收盤價在指數平均線之下 ,為空方顏色(淺藍)



5. MACD在零軸之上 ,為多方顏色(桃紅) , MACD在零軸之下 ,為空方顏色(淺藍)



6. MACD Diff在零軸之上 ,為多方顏色(桃紅) , MACDDiff在零軸之下 ,為空方顏色(淺藍)



7. RSI 在超買區之上 ,為多方顏色(桃紅) , RSI 在超賣區之下 ,為空方顏色(淺藍), RSI在區間內為盤整(黃色)



8. K值 在超買區之上 ,為多方顏色(桃紅) , K值在超賣區之下 ,為空方顏色(淺藍), K值在區間內為盤整(黃色)



由以上圖示可看出利用 PlotPaintBar 有幾個好處
1. 透過顏色明確的定位 ,可使交易者觀盤過程中, 掌握趨勢,進退有據 ,不任意作進出場變更.
2. 當觀盤中的副圖或均線指標線多的時候 ,可以用K棒顏色作副圖或均線的轉換
3. 其他用途 – 下篇介紹

沒有留言:

張貼留言