楼主: 挖矿专家
1247 2

[源码分享] 【每日一策】Matlab量化交易策略之 Aroon2股票隔夜 [推广有奖]

  • 0关注
  • 74粉丝

讲师

22%

还不是VIP/贵宾

-

威望
0
论坛币
2016 个
通用积分
5.2622
学术水平
21 点
热心指数
21 点
信用等级
21 点
经验
6055 点
帖子
403
精华
0
在线时间
151 小时
注册时间
2017-2-8
最后登录
2017-6-27

楼主
挖矿专家 发表于 2017-4-1 14:56:31 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
策略思路:

AROON指标分为两个具体指标,分别为AROONUP及AROONDOWN。其具体的计算方式为:
Aroon(上升)=[(计算期天数-最高价后的天数)/计算期天数]*100
Aroon(下降)=[(计算期天数-最低价后的天数)/计算期天数]*100

AROON上穿50,买入.
AROON下穿-50,平仓

策略源码:

  1. function Aroon2(n) % Aroon.
  2. % 其中,len为在多少日内全部完成突破
  3. targetList = traderGetTargetList(); % 在RunBackTest中选择好的标的.
  4. %获取目标资产信息
  5. HandleList = traderGetHandleList(); %
  6. %获取账户信息
  7. %=================================================================
  8. % RunBackTest的参数设置
  9. % n=15;
  10. %=================================================================

  11. global s; % 定义cc为全局变量
  12. if isempty(s) % 判断cc是否为空值
  13.     for i=1:length(targetList)
  14.         s(i).time=0;
  15.         s(i).BarNLong=0;
  16.         s(i).openprice=0;
  17.         s(i).stopprice=0;
  18.         s(i).highprice=0;
  19.     end
  20. end

  21. for i = 1:length(targetList) % 每个股票过一遍
  22.     [marketposition,~,~]=traderGetAccountPosition(HandleList(1),targetList(i).Market,targetList(i).Code);
  23.     %获取当前仓位

  24.     lags=n+2; % lags为策略需要往前获取多少天
  25.     %策略中每次取数据的长度
  26.    
  27.     barnum=traderGetCurrentBar(targetList(i).Market,targetList(i).Code); % K线的序号,后面会增加,前面的值对应的日期固定.
  28.     if(barnum<lags)
  29.         continue;
  30.     end
  31.     % 数据长度限制,排除了前lags根k线
  32.       
  33. %------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  34.     % 策略开始部分
  35.     [time,open,high,low,close,volume,turnover,openinterest] = traderGetKData(targetList(i).Market,targetList(i).Code,'day',1, 0-lags, 0,false,'FWard');
  36.    
  37.     if length(close)<n+2
  38.         continue;
  39.     end
  40.    
  41.     k1=0;
  42.     for j=1:n
  43.         if high(end-j+1)==max(high(end-14:end)) && k1==0
  44.             n_high=j-1;
  45.             k1=1;
  46.         end
  47.     end
  48.    
  49.     k2=0;
  50.     for j=1:n
  51.         if low(end-j+1)==min(low(end-14:end)) && k2==0
  52.             n_low=j-1;
  53.             k2=1;
  54.         end
  55.     end
  56.             
  57.     Aroon_up=(n-n_high)/n*100;
  58.     Aroon_dn=(n-n_low)/n*100;
  59.     Aroon=Aroon_up-Aroon_dn;
  60. %--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  61. % 计算前一天的
  62.     k1=0;
  63.     for j=1:n
  64.         if high(end-j)==max(high(end-15:end-1)) && k1==0
  65.             n_high_1=j-1;
  66.             k1=1;
  67.         end
  68.     end
  69.    
  70.     k2=0;
  71.     for j=1:n
  72.         if low(end-j)==min(low(end-15:end-1)) && k2==0
  73.             n_low_1=j-1;
  74.             k2=1;
  75.         end
  76.     end
  77.             
  78.     Aroon_up_1=(n-n_high_1)/n*100;
  79.     Aroon_dn_1=(n-n_low_1)/n*100;
  80.     Aroon_1=Aroon_up_1-Aroon_dn_1;   
  81. %--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  82.     EntryLong1=Aroon_1<50 && Aroon>50; % AROON上穿50,买入.
  83. % ===============================================================================================================
  84.     ExitLong1=Aroon_1>-50 && Aroon<-50; % AROON下穿-50,卖空
  85. % ===============================================================================================================   
  86.     shareNum=floor(100000000/300/close(end)/100)*100;
  87.    
  88.     if marketposition ==0 && EntryLong1
  89.         orderID1=traderBuy(HandleList(1),targetList(i).Market,targetList(i).Code,shareNum,0,'market','buy1'); % 开多单
  90.     end

  91.     if marketposition > 0 && ExitLong1 && floor(time(end))~=s(i).time; % 平仓情况1
  92.         traderPositionTo(HandleList(1),targetList(i).Market,targetList(i).Code,0,0,'market','sell1');
  93.     end

  94. end
复制代码

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



二维码

扫码加我 拉你入群

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

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


沙发
ghjktdf 发表于 2017-4-5 12:10:20
感谢分享

藤椅
65425856 发表于 2017-4-7 11:24:21
感谢分享

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

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