多头进场条件:收盘价大于广义布林带的上轨
空头进场条件:收盘价小于广义布林带的下轨
多头出场条件:收盘价小于中轨
空头出场条件:收盘价大于中轨
回测曲线:
策略代码:
function Aberration(Freq,len,plus,MaxshareNum) %
%Freq为输入频率
%len为计算使用的长度
%band为波动乘数
%shareNum为操作的手数
targetList = traderGetTargetList();
HandleList = traderGetHandleList();
for i=1:length(targetList)
marketposition=traderGetAccountPosition(HandleList(1),targetList(i).Market,targetList(i).Code);
[time,open,high,low,close,volume,turnover,openinterest] = traderGetKData(targetList(i).Market,targetList(i).Code,'day',1, 0-len, 0,false,'FWard');
if length(close)<len+1
continue;
end
stds=std(close(end-len:end));
means=mean(close(end-len:end));
con1=close(end)-means>plus*stds ;
con2=close(end)-means<-plus*stds;
con3=close(end)<means;
con4=close(end)>means;
shareNum=1;
% pos=MaxshareNum-abs(marketposition);
if marketposition==0
if con1
traderBuy(HandleList(1),targetList(i).Market,targetList(i).Code,shareNum,0,'market','buy');%开多单
elseif con2
traderSellShort(HandleList(1),targetList(i).Market,targetList(i).Code,shareNum,0,'market','sellshort');%开空单
end
end
if marketposition>0 && con3
traderSell(HandleList(1),targetList(i).Market,targetList(i).Code,shareNum,0,'market','sell');%平多单
end
if marketposition<0 && con4
traderBuyToCover(HandleList(1),targetList(i).Market,targetList(i).Code,shareNum,0,'market','buytocover');%平空单
end
end
更多免费策略源码下载请登录 http://www.atrader.com.cn/stra.php
Aberration策略源码下载:http://www.atrader.com.cn/stra.php?mod=model&pid=49