全部版块 我的主页
论坛 金融投资论坛 六区 金融学(理论版) 量化投资
2901 2
2017-03-27
SMA-ADX
策略原理:
         多头入场:价格大于65日均线,最高价大于均线,ADX均值大于20,最高价大于最近20日最高价上0.5倍ATR
         空头入场:价格小于65日均线,最低价小于均线,ADX均值大于20,最低价小于最近20日最低价下0.5倍ATR
         多头平仓:价格跌破均线
         空头平仓:价格突破均线

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

SMA-ADX.png


策略源码:

function Strategy1(default_unit,default_exitway,freq)%targetList = traderGetTargetList(); %获取目标资产信息HandleList = traderGetHandleList();%获取账户句柄for k=1:length(targetList);        %--------------------仓位、K线、当前bar的提取-----------------------------%    %获取当前仓位    [marketposition,~,~]=traderGetAccountPosition(HandleList(1),targetList(k).Market,targetList(k).Code);    %策略中每次取数据的长度    lags=80;    barnum=traderGetCurrentBar(targetList(k).Market,targetList(k).Code);    %数据长度限制    if(barnum<lags)        continue;    end    %获取K线数据    [time,open,high,low,close,volume,turnover,openinterest] = traderGetKData(targetList(k).Market,targetList(k).Code,'min',freq, 0-lags, 0,false,'FWard');    if length(close)<lags        continue;    end;       %-------------------------交易逻辑-------------------------------%    %----------入场信号--------------------%    [PDIma,NDIma,ADX]=DMI(close,high,low,14,14);    TRvalue=TR(close,high,low);    ATR=ma(TRvalue,20);    ADXma=ma(ADX,18);    ma1=ma(close,65);    highest=est(high,1);    lowest=est(low,-1);    buycon=close(end)>ma1(end) && highest(end-1)>ma1(end) && ADXma(end)>20 && high(end)>max(high(end-20:end-2))+0.5*ATR(end);    sellshortcon=close(end)<ma1(end) && lowest(end-1)<ma1(end) && ADXma(end)>20 && low(end)<min(low(end-20:end-2))-0.5*ATR(end);    sellcon=close(end)<ma1(end);    buytocovercon=close(end)>ma1(end);    %---------------------------入场操作--------------------------------%    if sellcon && marketposition>0        orderID1=traderPositionTo(HandleList(1),targetList(k).Market,targetList(k).Code,0,0,'market','sell');        if orderID1==0            continue;        end;    end;    if buytocovercon && marketposition<0        orderID2=traderPositionTo(HandleList(1),targetList(k).Market,targetList(k).Code,0,0,'market','sell');        if orderID2==0            continue;        end;    end;    if buycon && marketposition==0        buyunit=default_unit;        orderID3=traderBuy(HandleList(1),targetList(k).Market,targetList(k).Code,buyunit,0,'market','buy');        if orderID3==0            continue;        end;    end;    if sellshortcon && marketposition==0        sellshortunit=default_unit;        orderID4=traderSellShort(HandleList(1),targetList(k).Market,targetList(k).Code,sellshortunit,0,'market','sell');        if orderID4==0            continue;        end;    end; endend
更多免费策略源码下载请登录DigQuant社区-策略资源下载~



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2017-3-28 10:10:07
为啥没有16年的回测~
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2017-3-29 11:15:24
回测时间可以自己调的
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群