1.Dual Thrust 交易策略
1.1Dual Thrust策略介绍
Dual Thrust是一个趋势跟踪系统,由Michael Chalek在20世纪80年代开发,曾被Future Thruth杂志评为最赚钱的策略之一。Dual Thrust系统具有简单易用、适用度广的特点,其思路简单、参数很少,配合不同的参数、止盈止损和仓位管理,可以为投资者带来长期稳定的收益,被投资者广泛应用于股票、货币、贵金属、债券、能源及股指期货市场等。
在Dual Thrust交易系统中,对于震荡区间的定义非常关键,这也是该交易系统的核心和精髓。Dual Thrust系统使用Range = Max(HH-LC,HC-LL)来描述震荡区间的大小。其中HH是N日High的最高价,LC是N日Close的最低价,HC是N日Close的最高价,LL是N日Low的最低价。
1.2具体原理公式:
1、首先计算:
(1)N日High的最高价HH, N日Close的最低价LC;
(2)N日Close的最高价HC,N日Low的最低价LL;
(3)Range = Max(HH-LC,HC-LL)
(4)BuyLine = Open + K1×Range
(5)SellLine = Open + K2×Range
2.构造系统
(1)当价格向上突破上轨时,如果当时持有空仓,则先平仓,再开多仓;如果没有仓位,则直接开多仓;
(2)当价格向下突破下轨时,如果当时持有多仓,泽县平川,再开空仓;如果没有仓位,则直接开空仓;
2.本策略思路
1.当突破上界(Buyline),做多,并加均线过滤条件与交易量突变。
2.当突破下界(Sellline),做空,并加均线过滤条件与交易量突变。
3.出场使用滚动平均价止盈止损
3.策略代码分享
function DualThrust( N,freq,K1,K2,stop_rate )
%DualThrust思想加均线过滤条件加交易量变动
% Detailed explanation goes here
HandleList=traderGetHandleList();
TargetList=traderGetTargetList();
global TT
global eprice
if isempty(TT)||isempty(eprice)
TT=zeros(length(TargetList),1);
eprice=zeros(length(TargetList),1);
end
[ValidCash,MarketCap,OrderFrozen,MarginFrozen,PositionProfit] = traderGetAccountInfo(HandleList);
lags=60;
for i=1:length(TargetList)
[name,lastTD,Multiple,MinMove,TradingFeeOpen,TradingFeeClose,TradingFeeCloseToday,LongMargin,ShortMargin] = traderGetFutureInfo(TargetList(i).Market,TargetList(i).Code);
[time,open,high,low,close,volume,turnover,openinterest]=traderGetKData(TargetList(i).Market,TargetList(i).Code,‘day’,freq,0-lags,0,false,‘FWard’);
[Position,Frozen,AvgPrice] = traderGetAccountPosition(HandleList,TargetList(i).Market,TargetList(i).Code);
if length(close)<lags
continue;
end
sharenum=floor((ValidCash+MarketCap)0.8/length(TargetList)/close(end)/Multiple);
HH=max(high(end-N:end-1));
HC=max(close(end-N:end-1));
LC=min(close(end-N:end-1));
LL=min(low(end-N:end-1));
Range=max(HH-LC,HC-LL);
buyline=open(end)+K1Range;
sellline=open(end)-K2Range;
if TT(i)1
eprice(i)=AvgPrice;
TT(i)=0;
end
if Position0
if close(end)>buyline&&close(end)>mean(close(end-4:end))&&volume(end)>mean(volume(end-5:end))
orderID=traderBuy(HandleList,TargetList(i).Market,TargetList(i).Code,sharenum,0,‘Market’,‘buy’);
if orderID~=0
TT(i)=1;
end
elseif close(end)<sellline&&close(end)<mean(close(end-4:end))&&volume(end)>mean(volume(end-5:end))
orderID=traderSellShort(HandleList,TargetList(i).Market,TargetList(i).Code,sharenum,0,‘Market’,‘sell’);
if orderID~=0
TT(i)=1;
end
end
elseif Position>0
if close(end)>eprice(i)(1+3stop_rate)
eprice(i)=close(end);
elseif close(end)<eprice(i)(1-stop_rate)
traderPositionTo(HandleList,TargetList(i).Market,TargetList(i).Code,0,0,‘Market’,‘stoplong’);
end
else
if close(end)<eprice(i)(1-3stop_rate)
eprice(i)=close(end);
elseif close(end)>eprice(i)*(1+stop_rate)
traderPositionTo(HandleList,TargetList(i).Market,TargetList(i).Code,0,0,‘Market’,‘stoplong’);
end
end
end
end
3.2执行文件
targetList1 = traderGetCodeList(‘dce000’);
targetList2 =traderGetCodeList(‘czce000’);
targetList3 = traderGetCodeList(‘shfe000’);
targetList=[targetList1,targetList2,targetList3];
targetList=targetList([2 7 8 10 33 40 43 44 45 47]);
K1=0.5;
K2=0.5;
stop_rate=0.05;
freq=1;
N=10;
AccountList(1) = {‘FutureBackReplay’};
traderRunBacktest(‘DualThrust’,@DualThrust,{ N,freq,K1,K2,stop_rate },AccountList(1),targetList,‘day’,1,20100103,20161101,‘FWard’);
4.回测表现
随机挑选十支交易量活跃不同品种的期货自2010年1月至2016年11月进行日频回测