策略说明:
构造出多个多头形态和空头形态
多头进场条件:满足多头形态特征
空头进场条件:满足空头形态特征
多头出场条件:止损0.5%,盈利超过0.5%启动跟踪止盈,回撤1%出场
空头出场条件:止损0.5%,盈利超过0.5%启动跟踪止盈,回撤1%出场
回测曲线(由Auto-Trader提供回测报告)
策略源码:
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社区-策略资源下载~


雷达卡



京公网安备 11010802022788号







