全部版块 我的主页
论坛 金融投资论坛 六区 金融学(理论版) 量化投资
1022 5
2017-03-20
策略名称:FiveLine(趋势)

策略说明:
构造出多个多头形态和空头形态
多头进场条件:满足多头形态特征
空头进场条件:满足空头形态特征

多头出场条件:止损0.5%,盈利超过0.5%启动跟踪止盈,回撤1%出场
空头出场条件:止损0.5%,盈利超过0.5%启动跟踪止盈,回撤1%出场

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

Five line.png

策略源码:

function FiveLine(lags,freq,stopgap,trailinggap,shareNum)%五段线    targetList = traderGetTargetList();    HandleList = traderGetHandleList();    traderDailyCloseTime(145000);     % 每天14:50分平仓    如果没有日内平仓,去掉这句话就可以了。    [marketposition,~,~]=traderGetAccountPosition(HandleList(1),targetList(1).Market,targetList(1).Code);    [BarNumber,BarTime,BarOpen,BarHigh,BarLow,BarClose,BarVolume,BarTurnOver,BarOpenInterest] = traderGetCurrentBar(targetList(1).Market,targetList(1).Code);    if(BarNumber<lags)        return;    end    [time,open,high,low,close,volume,turnover,openinterest] = traderGetKData(targetList(1).Market,targetList(1).Code,'min',9, 0-lags, 0,false,'FWard');    buy=0;sell=0;    if rem(time(end),floor(time(end)))<(10/24)        return;    elseif rem(time(end),floor(time(end)))>(301/720)        return;    else        if close(end)<open(end)             if close(end-1)<open(end-1)                if close(end-2)<open(end-2)                            sell=1;                end            else                if close(end-2)<open(end-2)                    if close(end-3)<open(end-3)                        sell=1;                    end                else                   if close(end-3)<open(end-3)                       if close(end-4)>open(end-4)                           sell=1;                       end                   else                       buy=1;                   end                end            end        else            if close(end-1)<open(end-1)                if close(end-2)<open(end-2)                    if close(end-3)<open(end-3)                        if close(end-4)>open(end-4)                           sell=1;                       end                    end                else                    if close(end-3)>open(end-3)                        buy=1;                    end                end            end        end    end    if buy        if marketposition ==0 %             fprintf('%s  买  %s  %s  %d手  市价\n',datestr(BarTime),targetList(1).Market,targetList(1).Code,shareNum);            orderID1=traderDirectBuy(HandleList(1),targetList(1).Market,targetList(1).Code,shareNum,0,'market','buy');             traderStopLossByOrder(HandleList(1),orderID1,stopgap,'Percent','market','stoplossS');             traderStopTrailingByOrder(HandleList(1),orderID1,stopgap,'Percent',trailinggap,'Percent','market','trailingS');        end    end    if sell        if marketposition ==0 %             fprintf('%s  卖  %s  %s  %d手  市价\n',datestr(BarTime),targetList(1).Market,targetList(1).Code,shareNum);            orderID2=traderDirectSell(HandleList(1),targetList(1).Market,targetList(1).Code,shareNum,0,'market','sell');             traderStopLossByOrder(HandleList(1),orderID2,stopgap,'Percent','market','stoplossB');             traderStopTrailingByOrder(HandleList(1),orderID2,stopgap,'Percent',trailinggap,'Percent','market','trailingB');        end    endend




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

二维码

扫码加我 拉你入群

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

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

全部回复
2017-3-20 17:59:26
楼主写了一个系列?
二维码

扫码加我 拉你入群

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

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

2017-3-21 16:35:03
期待下一篇~~已关注楼主~~~
二维码

扫码加我 拉你入群

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

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

2017-3-22 10:14:29
楼主好人~
二维码

扫码加我 拉你入群

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

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

2017-3-29 22:18:17
谢谢分享
二维码

扫码加我 拉你入群

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

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

2017-3-31 18:41:46
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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