布林通道定義 - 轉錄自交易者的e甸園
簡單說當股價被夾在通道上緣和和中值中間所為成的區域,並且股價趨勢向上發展時,這時候就會形成明確的多方趨勢,也就是說當股價夾在通道上緣線和中值的平均線往右上方移動
這就是多頭勢。
2、布林通道進行壓縮時,即是區間整理,醞釀變盤方向
當一段趨勢行情結束之後便會進入到休息盤整區,此時多空會進行籌碼交換以利進入下一階段的趨勢行情,有可能是反轉,也有可能是原趨勢再走一段,這時候會看到布林通道由上升或下降的過程當中轉為水平的狀態,這時候當布林通道轉為水平發展時,就是股價在進行整理,而整理期間我最注重的就是波動率,布林通道的好處就是可以由帶寬觀察到股價的波動率,當股價由趨勢轉為整理時,此時若是股價沿著均線進行上下穿越式的洗盤,來回折返的幅度越大,布林通道的帶寬就會越寬,這表示股價的波動性很大,若是布林通道的帶寬越小
則表示股價的波動性比較小。
波動性對於觀察布林通道是一件很重要的事情,因為越大的波動性,表示多跟空的換手很積極,多跟空的交易都進行得十分激烈,波動性越大,表示籌碼越亂,只有籌碼混亂的情形之下才會造成大幅度的波動,相反的,若是股票籌碼穩定的進行換手,由於籌碼的流向都是被特定買盤穩穩的鎖定低接,自然就不會有大幅度的股價波動,一旦股價進行突破了,自然趨勢的力道就比較強。
本篇介紹一個國外交易者利用布林帶寬作為波動突破進場的交易策略
Input: Price(Close), StdDv(2), Length(9), ProfitPt(0);
Vars: TopBand(0), BotBand(0), BandRange(0), SellPrice(0), BuyPrice(0);
{Setup calculations - calculating bands & buy and sell prices }
TopBand = Average(Close, Length) + StdDev(Price, Length) * StdDv;
BotBand = Average(Close, Length) - StdDev(Price, Length) * StdDv;
BandRange = TopBand - BotBand;
{ 計算帶寬與最近 4根K棒平均值的比例作為多方/空方的進場價格 }
BuyPrice = Close * ( 1 + BandRange / Average(Close, 4) );
Sellprice = Close * ( 1 - BandRange / Average(Close, 4) ) ;
{ Entry orders }
Buy next bar at BuyPrice Stop;
Sell next bar at SellPrice Stop;
{ Exit at first profitable open }
If MarketPosition = 1 and Open tomorrow {Open next bar} > EntryPrice + ProfitPt + Commission *
CurrentContracts / BigPointValue then ExitLong ("Long Profit") next bar at Open Tomorrow stop ;
If MarketPosition = -1 and Open tomorrow {Open next bar} < EntryPrice - ProfitPt - Commission * CurrentContracts / BigPointValue then ExitShort ("Short Profit") next bar at Open Tomorrow stop; ******************************************************************************************
以下是將主要核心元素加到平時慣用的測試模型中,並增加多空各自的變數,然後利用隨機參數的方式,分別針對出場的規則作了比較如下表。
不同出場規則的績效比較
台指期 日K 多空留倉 交易週期 2004/8/30~ 2014/8/29 交易成本 1200
原始出場規則 6
出場規則 2
出場規則 3
測試程式碼
input:ExitType(1) ;
inputs:NBarL(2),NBarS(2),TradeProfit(0.03),TradeStopLoss(0.03),ATRs_L(2),ATRs_S(2);
inputs:
Price(Close),BarLenL(9),StdL(2),BarLenS(9),StdS(2),AvgL(4),AvgS(4),ProfitPt(0);
vars: IsBalanceDay(False),MP(0),PF(0),PL(0);
Vars: TopBand(0), BotBand(0), BandRange(0), SellPrice(0), BuyPrice(0);
MP = MarketPosition ;
if DAYofMonth(Date) > 14 and DAYofMonth(Date) < 22 and DAYofWeek(Date)= 3 then isBalanceDay = True else isBalanceDay =False ;
PF = AvgPrice*TradeProfit ;
PL = AvgPrice*TradeStopLoss ;
{Setup calculations - calculating bands & buy and sell prices }
TopBand = Average(Close, BarLenL) + StdDev(Price, BarLenL) * StdL;
BotBand = Average(Close, BarLenS) - StdDev(Price, BarLenS) * StdS;
BandRange = TopBand - BotBand;
BuyPrice = Close * ( 1 + BandRange / Average(Close, AvgL) );
Sellprice = Close * ( 1 - BandRange / Average(Close, AvgS) ) ;
{ Entry orders }
Buy next bar at BuyPrice Stop;
Sell next bar at SellPrice Stop;
{原始出場規則}
if ExitType = 6 then Begin
{ Exit at first profitable open }
If MarketPosition = 1 and Open next bar > EntryPrice + ProfitPt + Commission *
CurrentContracts / BigPointValue then ExitLong ("Long Profit") next bar at Open;
If MarketPosition = -1 and Open next bar < EntryPrice - ProfitPt - Commission * CurrentContracts / BigPointValue then ExitShort ("Short Profit") next bar at Open;
end;
{測試模型的出場規則 }
if ExitType = 1 then SetStopLoss(PL * BigPointValue) ;
if ExitType = 2 then Begin
SetStopLoss(PL * BigPointValue) ;
setProfitTarget(PF * BigPointValue) ;
end;
if ExitType = 3 then Begin
if MP > 0 and BarsSinceEntry = NBarL then ExitLong next bar at Market ;
if MP < 0 and BarsSinceEntry = NBarS then ExitShort next bar at Market ;
end;
if ExitType = 4 then Begin
SetStopLoss(PL * BigPointValue) ;
setProfitTarget(PF * BigPointValue) ;
if MP > 0 and BarsSinceEntry = NBarL then {Sell } ExitLong next bar at Market ;
if MP < 0 and BarsSinceEntry = NBarS then {Buy} ExitShort next bar at Market ;
end;
if ExitType = 5 then Begin
{******************************************************************* Description : ATR Trailing Stop Long Exit Provided By : Omega Research, Inc. (c) Copyright 1999 ********************************************************************}
{Inputs: ATRs_L(3);}
Variables: PosHigh(0), ATRVal_L(0);
ATRVal_L = AvgTrueRange(10) * ATRs_L;
If BarsSinceEntry = 0 Then PosHigh = High;
If MarketPosition = 1 Then Begin If High > PosHigh Then PosHigh = High;
ExitLong ("ATR") Next Bar at PosHigh - ATRVal_L Stop;
End else ExitLong ("ATR eb") Next bar at High - ATRVal_L Stop;
{*******************************************************************
Description : ATR Trailing Stop Short Exit
Provided By : Omega Research, Inc. (c) Copyright 1999
*******************************************************************}
{Inputs: ATRs_S(3);}
Variables: PosLow(0), ATRVal_S(0);
ATRVal_S = AvgTrueRange(10) * ATRs_S;
If BarsSinceEntry = 0 Then PosLow = Low;
If MarketPosition = -1 Then Begin
If Low < PosLow Then PosLow = Low;
ExitShort ("ATR_1") Next Bar at PosLow + ATRVal_S Stop;
End else ExitShort ("ATR_1 eb") Next bar at Low + ATRVal_S Stop;
end;
if IsBalanceDay then setExitonClose ;
觀察商品價格進入盤整帶時,最注重的就是價格波動過程所形成的帶寬,當波動率越大,帶寬就越寬,當個波動率越小,帶寬就越窄,窄幅的布林通道的未來趨勢性會比寬帶的布林通道來的強,這是布林通道的重點,特別是若成交量也逐步增加時更為明顯。
0 意見:
張貼留言