包寧杰強(qiáng)盜交易系統(tǒng)[系統(tǒng)交易]
引言:
文中提到此系統(tǒng)摘自「Building Winning Trading Systems with TradeStation」(Pruitt與Hill,2003)。包寧杰強(qiáng)盜(Bollinger Bandit)交易系統(tǒng)計算價格的標(biāo)準(zhǔn)差,基于均數(shù)復(fù)歸的精神,「當(dāng)價格突破上N個標(biāo)準(zhǔn)差(N為策略參數(shù))反轉(zhuǎn)時,作空」,反之,「當(dāng)價格突破下N個標(biāo)準(zhǔn)差反轉(zhuǎn)時,作多」。但Pruitt與Hill的實證中發(fā)現(xiàn),反向操作反而更好,亦即採取「當(dāng)價格突破上N個標(biāo)準(zhǔn)差(N為策略參數(shù))時,作多」,反之,「當(dāng)價格突破下N個標(biāo)準(zhǔn)差時,作空」,并將策略參數(shù)設(shè)計成可適應(yīng)性調(diào)整的動態(tài)設(shè)定。發(fā)文者提供了系統(tǒng)編碼與實證績效結(jié)果,并自行作了改進(jìn)。
正文:
今天要報告的是”Building Winning Trading Systems with TradeStation”這本書裡面的第二個交易系統(tǒng)。名字叫做包寧杰強(qiáng)盜Bollinger Bandit交易系統(tǒng)。
要先講一下Bollinger Band這個系統(tǒng),Bollinger Band這個通道的名詞,最早是由John Bollinger在1960年代所提出的觀念。計算方式就是先取一條簡單移動平均線,然后在這條移動平均線上下個取一個標(biāo)準(zhǔn)差的距離,來分別當(dāng)作上下通道。Bollinger認(rèn)為在統(tǒng)計學(xué)的觀念來說,在移動平均線上下各取一個標(biāo)準(zhǔn)差的距離,等于總共是有兩個標(biāo)準(zhǔn)差的寬度的通道,應(yīng)該會包含95%的價格波動。所以當(dāng)價格位于到上通道的上面的時候,就很有可能會往下回歸均線。這時候就可以在價格往下穿透上通道的時候做空,也就是把上通道當(dāng)作壓力區(qū)間來操作。(下通道則相反)
但是George Pruitt & John Hill做的很多測試發(fā)現(xiàn)。Bollinger Band的上通道通常并不是壓力線,而通常會是可以成功做多的突破線。也就是說我們應(yīng)該在價格突破上通道的時候做多才對。
所以作者就將Bollinger Band的訊號反過來操作。同時也加入了一些其他的設(shè)計,其中一個設(shè)計就是由King Keltner trading system的系統(tǒng)改進(jìn)而來的。因為在King Keltner trading system當(dāng)中,出場的機(jī)制是當(dāng)價位回到移動平均線的時候就出場。但是有時候移動平均線的追蹤速度太慢了,導(dǎo)致我們有時候真正出場的時候會回吐太多的獲利出去。這種情形常常會讓很多人吐血。所以他們設(shè)計的出場機(jī)制會隨著進(jìn)場時間的增加,而更緊密的追蹤價位。作法就是隨著進(jìn)場之后的時間增加,把出場的移動平均線的計算長度,逐漸的減少。所以剛進(jìn)場的時候的停損金額是會比較寬的,但是進(jìn)場時間越長,計算出場的移動平均線的時間長度會越短,也就代表這條出場移動平均線會越緊密的追蹤價位。所以當(dāng)最后價格反轉(zhuǎn)不利于我們的時候,我們比較不會回吐太多的獲利出去。但是這個時間長度最少只有減到10而已,以防止移動秤均線太貼緊價位而很容易就打到停損出場。
最后作者加了一個簡單的濾網(wǎng)來決定多空的方向。就是如果今天的收盤價比30天前的收盤價高的話就只做多,如果今天收盤價比30天之前的收盤價低的話就只做空。
下面就是書上的程式碼:
{Bollinger Bandit by George Pruitt—program uses Bollinger Bands and Rate of
change to determine entry points. A trailing stop that is proportional with
the amount of time a trade is on is used as the exit technique.}
Inputs: bollingerLengths(50),liqLength(50),rocCalcLength(30);
Vars: upBand(0),dnBand(0),liqDays(50),rocCalc(0);
upBand = BollingerBand(Close,bollingerLengths,1.25);
dnBand = BollingerBand(Close,bollingerLengths,-1.25);
rocCalc = Close - Close[rocCalcLength-1]; {remember to subtract 1}
if(MarketPosition <> 1 and rocCalc > 0) then Buy("BanditBuy")tomorrow upBand stop;
if(MarketPosition <>-1 and rocCalc < 0) then SellShort("BanditSell") tomorrow dnBand stop;
if(MarketPosition = 0) then liqDays = liqLength;
if(MarketPosition <> 0) then begin
liqDays = liqDays - 1;
liqDays = MaxList(liqDays,10);
end;
if(MarketPosition = 1 and Average(Close,liqDays) < upBand) then Sell("Long Liq") tomorrow Average(Close,liqDays) stop;
if(MarketPosition = -1 and Average(Close,liqDays) > dnBand) then BuyToCover("Short Liq") tomorrow Average(Close,liqDays) stop;
而作者測試1982-2002年這20年的歷史資料,所得出的來結(jié)果是這樣的。
BB Performance.JPG
BB Performance.JPG (86.56 KiB) 被瀏覽 1223 次
Bollinger Bandit系統(tǒng)像King Keltner系統(tǒng)一樣,同樣的也是把上下通道的寬度固定住了,這裡是固定在標(biāo)準(zhǔn)差的1.25倍。所以我同樣做了個小小的修改,讓我們可以試試看不同的通道寬度,對于績效的影響如何。修改后的程式碼如下:(轉(zhuǎn)自 http://www.kzuj.com.cn/2016/04/08/35133.shtml )
{Bollinger Bandit by George Pruitt—program uses Bollinger Bands and Rate of
change to determine entry points. A trailing stop that is proportional with
the amount of time a trade is on is used as the exit technique.}
Inputs: bollingerLengths(50),liqLength(50),rocCalcLength(30),StdDevRatio(1);
Vars: upBand(0),dnBand(0),liqDays(50),rocCalc(0);
upBand = BollingerBand(Close,bollingerLengths,StdDevRatio);
dnBand = BollingerBand(Close,bollingerLengths,-StdDevRatio);// www.kzuj.com.cn
rocCalc = Close - Close[rocCalcLength-1]; {remember to subtract 1}
if(MarketPosition <> 1 and rocCalc > 0) then Buy("BanditBuy")tomorrow upBand stop;
if(MarketPosition <>-1 and rocCalc < 0) then SellShort("BanditSell") tomorrow dnBand stop;
if(MarketPosition = 0) then liqDays = liqLength;
if(MarketPosition <> 0) then begin
liqDays = liqDays - 1;
liqDays = MaxList(liqDays,10);
end;
if(MarketPosition = 1 and Average(Close,liqDays) < upBand) then Sell("Long Liq") tomorrow Average(Close,liqDays) stop;
if(MarketPosition = -1 and Average(Close,liqDays) > dnBand) then BuyToCover("Short Liq") tomorrow Average(Close,liqDays) stop;
如果有朋友有研究過上一個介紹的King Keltner系統(tǒng)的話,應(yīng)該會發(fā)現(xiàn)Bollinger Bandit跟King Keltner的績效差不多。這是因為這兩個系統(tǒng)的原理基本上就是很類似的,都是屬于上下通道突破的系統(tǒng),只是出場跟濾網(wǎng)的設(shè)計不一樣而已。所以如果有朋友想要做multi-system的portfolio的話,要注意這兩個交易系統(tǒng)的相關(guān)性會是比較高的。而我們設(shè)計portfolio的原則,就是應(yīng)該要採用相關(guān)性較低的系統(tǒng)才好。
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 511411198 進(jìn)行 有償 編寫!(不貴!點擊查看價格!)
- 上一篇:Price Channel Breakout 交易系統(tǒng)簡價及…
- 下一篇:沒有了!
相關(guān)文章
-
沒有相關(guān)內(nèi)容