恒溫器Thermostat交易系統(tǒng)-會換檔的交易系統(tǒng) EASYLANGUAGE語言[系統(tǒng)交易]
引言:
此文介紹「恒溫器交易系統(tǒng)」(Thermostat Trading Strategy)的設(shè)計原理,此系統(tǒng)「在趨勢市場中採用順勢系統(tǒng),在擺盪市場中採用擺盪系統(tǒng)」,系統(tǒng)設(shè)計的關(guān)鍵在于決定市場類別(順勢或擺盪)的轉(zhuǎn)折點,此系統(tǒng)使用Choppy Market Index為指標(biāo)(指標(biāo)值介于0~100之間,指數(shù)越大代表市場越有趨勢)。以此指標(biāo)判斷,策略系統(tǒng)即可判別市場類別,并引用不同的技術(shù)指標(biāo)。發(fā)文者也提供了系統(tǒng)編碼與實證績效結(jié)果。
正文:
因為市場不會永遠存在趨勢,所以才會有人想說希望有一種交易系統(tǒng)可以適用在趨勢市場和擺盪市場。而Thermostat Trading Strategy(恒溫器交易系統(tǒng))的設(shè)計原理,就是在趨勢市場中採用順勢系統(tǒng),在擺盪市場中採用擺盪系統(tǒng)。有點像是換檔的感覺,而決定換檔時機的指標(biāo),就是之前報告過的 ChoppyMarketIndex,這個指標(biāo)是會介于0-100之間,指數(shù)越大,代表現(xiàn)在的市場越有趨勢。整個系統(tǒng)的架構(gòu),可以簡化的寫成下面這樣:
If ChoppyMarketIndex < 20 then begin
擺盪系統(tǒng)內(nèi)容;
end;
If ChoppyMarketIndex >= 20 then begin
順勢系統(tǒng)內(nèi)容;
End;
架構(gòu)就是這麼簡單而已,剩下的只是把擺盪系統(tǒng)和順勢系統(tǒng)的內(nèi)容放進去這個架構(gòu)裡面而已。順勢系統(tǒng)的內(nèi)容主要是延續(xù)使用 Bollinger Bandit系統(tǒng)的內(nèi)容,而擺盪系統(tǒng)則是加上的簡單的型態(tài)識別(pattern recognition)的開盤區(qū)間突破系統(tǒng)而已。下面分別就這兩種系統(tǒng)作報告:
(轉(zhuǎn)自 http://m.kzuj.com.cn/2016/04/08/35134.shtml)
擺盪系統(tǒng):
在擺盪市場中,通常會存在一種現(xiàn)象,就是如果今天價格上漲的話,那麼明天的價格就比較傾向于會下跌。而今天價格如果下跌的話,那麼明天的價格就比較傾向于上漲,而這也正是擺盪市場的特性。所以我們定義如果今天的收盤價如果高于昨天的 (最高價+最低價+收盤價) / 3的話,那麼明天就會一個 sell easier day,代表明天價格應(yīng)該會比較傾向下跌。相反的,我們也定義如果今天的收盤價低于昨天的 (最高價+最低價+收盤價) / 3的話,那麼明天就會是一個buy easier day,代表明天價格應(yīng)該會比較傾向上漲。
在buy easier day的時候,只有代表著價格比較具有上漲的可能性而已,并不是指價格一定會上漲。所以我們必須設(shè)定做多和做空這兩邊的entry,只是這兩邊entry的門檻不一樣而已,做多的門檻比較低,比較容易。反而做空的門檻比較高,比較難。所以在buy easier day的時候,我們會設(shè)定進場的規(guī)則是這樣的:
Initiate a long position at the open price + 50% of the ten-day average true range.
Initiate a short position at the open price - 75% of the ten-day average true range.
而如果是sell easier day的話,那我們則會把進場的規(guī)則設(shè)為這樣:
Initiate a short position at the open price - 50% of the ten-day average true range.
Initiate a long position at the open price + 75% of the ten-day average true range.
而在擺盪市場中,有時候市場會有假的,失敗的波動,這種假的波動常常會讓我們被巴來巴去,所以這裡我們加入了一個簡單的濾網(wǎng)來避免這種情形。如果我們的buy stop 低于三天的最低價的平均,則就把buy stop提高到三天的最低價的平均。而如果我們的sell stop高于三天最高價的平均,則把sell stop下降到三天最高價的平均。( www,cxh99.com )
順勢系統(tǒng):
如果當(dāng)ChoppyMarketIndex的指標(biāo)高于20的時候,代表現(xiàn)在市場進入趨勢了,所以我們也跟著改用順勢系統(tǒng)。這裡我們所採用的順勢系統(tǒng)就是之前報告過的Bollinger Bandit系統(tǒng)。當(dāng)價格突破上通道的時候建立多頭部位,當(dāng)價格跌破下通道的時候則建立空頭部位。而當(dāng)有部位在手上的時候,而價格回到50天移動平均線的時候,我們就平倉出場。
而當(dāng)這個系統(tǒng)在擺盪和趨勢這兩種模式當(dāng)中轉(zhuǎn)換的時候,有時候會有部位在手上。當(dāng)從趨勢市場轉(zhuǎn)換成擺盪市場的時候,如果有在趨勢市場當(dāng)中建立的部位,則我們就讓擺盪系統(tǒng)的進場訊號發(fā)生的時候才來結(jié)束這個部位。但是當(dāng)市場從擺盪市場變成趨勢市場的時候,如果我們有在擺盪市場裡面建立的部位的話,那麼我們就用三倍ATR的保護性停損來保護我們的部位。因為如果要用50天移動平均線才讓我們出場的話,那可能會讓我們保留這個錯誤的部位太久而造成太多的損失。
下面就是這個系統(tǒng)的程式碼:
{Thermostat by George Pruitt
Two systems in one. If the ChoppyMarketIndex is less than 20 then we are in a
swing mode. If it is greater than or equal to 20 then we are in a trend mode.
Swing system is an open range breakout incorporating a buy easier/sell easier
concept. The trend following system is based on bollinger bands and is
similar to the Bollinger Bandit program.}
Inputs: bollingerLengths(50),trendLiqLength(50),numStdDevs(2),swingPrcnt1(0.50),swingPrcnt2(0.75),atrLength(10),swingTrendSwitch(20);
Vars:cmiVal(0),buyEasierDay(0),sellEasierDay(0),trendLokBuy(0),trendLokSell(0),keyOfDay(0),swingBuyPt(0),swingSellPt(0),trendBuyPt(0),trendSellPt(0),swingProtStop(0);
cmiVal = ChoppyMarketIndex(30);
buyEasierDay = 0;
sellEasierDay = 0;
trendLokBuy = Average(Low,3);
trendLokSell= Average(High,3);
keyOfDay = (High + Low + Close)/3;
if(Close > keyOfDay) then sellEasierDay = 1;
if(Close <= keyOfDay) then buyEasierDay = 1;
if(buyEasierDay = 1) then
begin
swingBuyPt = Open of tomorrow + swingPrcnt1*AvgTrueRange(atrLength);
swingSellPt = Open of tomorrow - swingPrcnt2*AvgTrueRange(atrLength);
end;
if(sellEasierDay = 1) then
begin
swingBuyPt = Open of tomorrow + swingPrcnt2*AvgTrueRange(atrLength);
swingSellPt = Open of tomorrow - swingPrcnt1*AvgTrueRange(atrLength);
end;
swingBuyPt = MaxList(swingBuyPt,trendLokBuy);
swingSellPt = MinList(swingSellPt,trendLokSell);
trendBuyPt = BollingerBand(Close,bollingerLengths,numStdDevs);
trendSellPt = BollingerBand(Close,bollingerLengths,- numStdDevs);
if(cmiVal < swingTrendSwitch)then
begin
if (MarketPosition <> 1) then Buy("SwingBuy") next bar at swingBuyPt stop;
if(MarketPosition <> -1) then SellShort("SwingSell") next bar at swingSellPt stop;
end
else
begin
swingProtStop = 3*AvgTrueRange(atrLength);
Buy("TrendBuy") next bar at trendBuyPt stop;
SellShort("TrendSell") next bar at trendSellPt stop;
Sell from Entry("TrendBuy") next bar at Average(Close,trendLiqLength) stop;
BuyToCover from Entry("TrendSell") next bar at Average(Close,trendLiqLength) stop;
Sell from Entry("SwingBuy") next bar at EntryPrice – swingProtStop stop;
BuyToCover from Entry("SwingSell") next bar at EntryPrice + swingProtStop stop;
end;
而下面則是這個系統(tǒng)在1982-2002這20年的績效表現(xiàn),看來比之前報告的King Kelthner和Bollinger Bandit系統(tǒng)績效來的好。
thermostat.JPG
thermostat.JPG (87.89 KiB) 被瀏覽 1235 次
有興趣的朋友可以拿來測試一下看看,不過我自己測試了最近幾年的外匯,指數(shù),金屬,能源,農(nóng)產(chǎn)品等等。發(fā)現(xiàn)績效還好而已,所以想要直接拿來套用的人可能會失望了。不過這樣的系統(tǒng)開發(fā)的邏輯,倒是可以值得我們學(xué)習(xí)的。謝謝。
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 511411198 進行 有償 編寫!(不貴!點擊查看價格!)
- 上一篇:包寧杰強盜交易系統(tǒng)
- 下一篇:沒有了!
相關(guān)文章
-
沒有相關(guān)內(nèi)容