策略思路:
对两条均线的20组参数循环,满足金叉分数+1
当分数大于12分时,多头入场,
当有仓位时,分数小于8分,则平仓出场
回测曲线(由Auto-Trader提供回测报告)
均线打分.png (77.9 KB, 下载次数: 3)
2017-3-7 14:36 上传
function Strategy1(default_unit,default_exitway,freq)%targetList = traderGetTargetList(); %获取目标资产信息HandleList = traderGetHandleList();%获取账户句柄global entrybar;for k=1:length(targetList); %--------------------仓位、K线、当前bar的提取-----------------------------% %获取当前仓位 [marketposition,~,~]=traderGetAccountPosition(HandleList(1),targetList(k).Market,targetList(k).Code); %策略中每次取数据的长度 lags=90; dlags=20; barnum=traderGetCurrentBar(targetList(k).Market,targetList(k).Code); %数据长度限制 if(barnumlma(end) points=points+1; end; end; buycon=points>12; sellshortcon=points<8; if default_exitway==1 sellcon=points<8; buytocovercon=points>12; 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; entrybar(k)=barnum; 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; entrybar(k)=barnum; end; endend
更多免费策略源码下载请登录DigQuant社区-策略资源 页面下载,www. digquant.com.cn/stra.php