1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 量化交易策略matlab交易方案 Matlab量化交易策略之 GFTD+止损 附源码

量化交易策略matlab交易方案 Matlab量化交易策略之 GFTD+止损 附源码

时间:2019-08-24 17:53:34

相关推荐

量化交易策略matlab交易方案 Matlab量化交易策略之 GFTD+止损 附源码

策略思路:

GFED模型,趋势跟踪策略,利用K线收盘价的涨跌进行判断,真正交易前,需经历交易启动,到交易信号发出的过程,并且买入和卖出分别当做独立的系统进行计算。当买入计数达到4,做多,当卖出计数达到4,做空。并利用ATR控制止损和加仓。

回测曲线(由Auto-trader提供回测报告)

GFTD+止损.png (218.28 KB, 下载次数: 3)

-3-27 16:00 上传

策略源码:

function atdloss(freq)targetList = traderGetTargetList();HandleList = traderGetHandleList();global record;global record1;global record2;global record3;for i=1:length(targetList) marketposition=traderGetAccountPosition(HandleList(1),targetList(i).Market,targetList(i).Code); barnum=traderGetCurrentBar(targetList(i).Market,targetList(i).Code); len=30; dlen=31; [time,open,high,low,close,volume,turnover,openinterest] = traderGetKData(targetList(i).Market,targetList(i).Code,'min',freq, 0-len, 0,false,'FWard'); [Dtime,Dopen,Dhigh,Dlow,Dclose,Dvolume,Dturnover,Dopeninterest] = traderGetKData(targetList(i).Market,targetList(i).Code,'day',1, 0-dlen, 0,false,'FWard'); if length(close)close(end-4) ud=1; elseif close(end)=record3{i}.bhigh(2)&&high(end)>record3{i}.bhigh(1)&&close(end)>record3{i}.bclose(1) record3{i}.bcou=record3{i}.bcou+1; end elseif record3{i}.b>1&&record3{i}.bcou<4 record3{i}.bcou=0; record3{i}.b=0; end %卖出交叉计数 if record3{i}.s==1 if close(end)<=record3{i}.slow(2)&&low(end)>record3{i}.slow(1)&&close(end)>record3{i}.sclose(1) record3{i}.scou=record3{i}.scou+1; end elseif record3{i}.s>1&&record3{i}.scou<4 record3{i}.scou=0; record3{i}.s=0; end %判断买入启动是否达成 if record3{i}.bcou==4 con1=1; record3{i}.b=0; record3{i}.bcou=0; record3{i}.bclose=[]; record3{i}.bhigh=[]; record3{i}.blow=[]; else con1=0; end if record3{i}.scou==4 con2=1; record3{i}.s=0; record3{i}.scou=0; record3{i}.sclose=[]; record3{i}.shigh=[]; record3{i}.slow=[]; else con2=0; end %------------------止损线 ATR=ATR(Dhigh,Dlow,Dclose,20); %-------------------------------满仓上移--------------% if record1{i}.m>3 if close(end)>record1{i}.entryp+2*ATR(end)&&(marketposition>0) record1{i}.entryp= record1{i}.entryp+2*ATR(end); elseif close(end)0&&record1{i}.m~=0 if close(end)record1{i}.entryp+0.5*ATR(end) order= traderPositionTo(HandleList(1),targetList(i).Market,targetList(i).Code,0,0,'market','sell'); if order~=0record1{i}.m=0;record1{i}.entryp=close(end);record1{i}.entrybar=0; end end end sharenum=5; %---------------入场-------------% if con1&&(record1{i}.m==0)&&(marketposition==0) order=traderBuy(HandleList(1),targetList(i).Market,targetList(i).Code,sharenum,0,'market','buy'); %%%%做多 if order~=0 record1{i}.m= record1{i}.m+1; record1{i}.entryp=close(end); record1{i}.entrybar=barnum; end end if con2&&(record1{i}.m==0)&&(marketposition==0) order=traderSellShort(HandleList(1),targetList(i).Market,targetList(i).Code,sharenum,0,'market','buy'); %%%%做多 if order~=0 record1{i}.m= record1{i}.m+1; record1{i}.entryp=close(end); record1{i}.entrybar=barnum; end end %----------------------------加仓----------------------% ifclose(end)>record1{i}.entryp+2*ATR(end)&&(record1{i}.m<=3)&&(marketposition>0) order=traderBuy(HandleList(1),targetList(i).Market,targetList(i).Code,sharenum,0,'market','buy'); %%%%做多 if order~=0 record1{i}.m= record1{i}.m+1; record1{i}.entryp=close(end); record1{i}.entrybar=barnum; end end ifclose(end)

更多免费策略源码下载请登录DigQuant社区-策略资源下载~ ww

GFTD+止损.png

(218.28 KB, 下载次数: 7)

-3-27 16:00 上传

GFTD+止损.png

(218.28 KB, 下载次数: 0)

-3-27 15:59 上传

GFTD+止损.png

(218.28 KB, 下载次数: 0)

-3-27 15:59 上传

GFTD+止损.png

(218.28 KB, 下载次数: 0)

-3-27 15:57 上传

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。