楼主: ghjktdf
1184 0

[源码分享] 【每日一策】Matlab量化交易之 DUAL TRUST 非日内 [推广有奖]

  • 1关注
  • 1粉丝

硕士生

19%

还不是VIP/贵宾

-

威望
0
论坛币
166 个
通用积分
0
学术水平
1 点
热心指数
2 点
信用等级
1 点
经验
1340 点
帖子
225
精华
0
在线时间
39 小时
注册时间
2017-2-16
最后登录
2017-6-26

楼主
ghjktdf 发表于 2017-4-6 14:17:29 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
策略原理:
         仍然按照经典的DualThrust定义上轨和下轨,不设止盈止损,日内不平仓。

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

DUAL TRUST 非日内.png

策略源码:

  1. function Strategy1(default_unit,default_exitway,freq)%

  2. targetList = traderGetTargetList();
  3. %获取目标资产信息
  4. HandleList = traderGetHandleList();
  5. %获取账户句柄
  6. global enterprice;
  7. for k=1:length(targetList);
  8.    
  9.     %--------------------仓位、K线、当前bar的提取-----------------------------%
  10.     %获取当前仓位
  11.     [marketposition,~,~]=traderGetAccountPosition(HandleList(1),targetList(k).Market,targetList(k).Code);
  12.     %策略中每次取数据的长度
  13.     lags=200;
  14.     dlags=10;
  15.     barnum=traderGetCurrentBar(targetList(k).Market,targetList(k).Code);
  16.     %数据长度限制
  17.     if(barnum<lags)
  18.         continue;
  19.     end
  20.     %获取K线数据
  21.     [time,open,high,low,close,volume,~,~] = traderGetKData(targetList(k).Market,targetList(k).Code,'min',freq, 0-lags, 0,false,'FWard');
  22.     [Dtime,Dopen,Dhigh,Dlow,Dclose,Dvolume,~,~] = traderGetKData(targetList(k).Market,targetList(k).Code,'day',1, 0-dlags, 0,false,'FWard');
  23.     if length(close)<lags || length(Dclose)<dlags
  24.         continue;
  25.     end;   
  26.     %-------------------------交易逻辑-------------------------------%
  27.     %----------入场信号--------------------%
  28.     N=3;
  29.     k1=0.5;
  30.     k2=0.5;
  31.     stoplossratio=0.5;
  32.     unit=1;
  33.     HH=max(Dhigh(end-N:end-1));
  34.     HC=max(Dclose(end-N:end-1));
  35.     LC=min(Dclose(end-N:end-1));
  36.     LL=min(Dlow(end-N:end-1));
  37.     range=max(HH-LC,HC-LL);
  38.     upline=Dopen(end)+k1*range;
  39.     dnline=Dopen(end)-k2*range;
  40.     buycon=close(end)>upline;
  41.     sellshortcon=close(end)<dnline;
  42.     sellcon=0;
  43.     buytocovercon=0;
  44.     if enterprice~=0
  45.         sellcon=close(end)<dnline || close(end)<enterprice*(1-stoplossratio);
  46.         buytocovercon=close(end)>upline || close(end)>enterprice*(1+stoplossratio);
  47.     end;
  48.     if buytocovercon && marketposition<0
  49.         orderID1=traderBuyToCover(HandleList(1),targetList(k).Market,targetList(k).Code,'all',0,'market','buy');
  50.         if orderID1==0
  51.             continue;
  52.         end;
  53.     end;
  54.     if sellcon && marketposition>0
  55.         orderID1=traderSell(HandleList(1),targetList(k).Market,targetList(k).Code,'all',0,'market','sell');
  56.         if orderID1==0
  57.             continue;
  58.         end;
  59.     end;
  60.     if buycon && marketposition<=0
  61.         orderID1=traderBuy(HandleList(1),targetList(k).Market,targetList(k).Code,unit,0,'market','buy');
  62.         if orderID1==0
  63.             continue;
  64.         end;
  65.         enterprice=close(end);
  66.     end;
  67.     if sellshortcon && marketposition>=0
  68.         orderID1=traderSellShort(HandleList(1),targetList(k).Market,targetList(k).Code,unit,0,'market','sellshort');
  69.         if orderID1==0
  70.             continue;
  71.         end;
  72.         enterprice=close(end);
  73.     end;
  74. end
  75. end
复制代码


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



二维码

扫码加我 拉你入群

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

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


已有 1 人评分经验 论坛币 收起 理由
fantuanxiaot + 22 + 22 精彩帖子

总评分: 经验 + 22  论坛币 + 22   查看全部评分

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jr
拉您进交流群
GMT+8, 2026-1-28 13:12