对任何一个简单的策略,我设置了一个全局变量n,每次开仓都n=n+1,最后的n居然和评测数据里的交易次数相差甚大,是什么原因,请指教。代码如下:
VARIABLE: n:=0,days:=0;
手数:=1;
ma5:=ma(c,5);
ma10:=ma(c,10);
up:=cross(ma5,ma10);
down:=cross(ma10,ma5);
开多条件:= holding=0 and up;
开空条件:= holding=0 and down;
平多条件:= holding>0 and down;
平空条件:= holding<0 and up;
if 平空条件 then 平空1:sellshort( 1, 手数,market);
if 平多条件 then 平多1:sell( 1, 手数,market);
if 开空条件 then begin
n:=n+1;
开空1:buyshort( 1 , 手数,market);
end
if 开多条件 then begin
n:=n+1;
开多1:buy( 1, 手数,market);
end
dd:=date();
if dd<> ref(dd,1) then days:=days+1;
if DATE()=1130730 and time()=151500 then begin // 测试的最后一根分钟线
str:= NUMTOSTR(n,0)+' '+ NUMTOSTR(days,0);
STRINGTOFILE('d:\debugfile.txt',str);
end
说明,我已把资金改成10000万,避免因资金不足造成的没钱开仓的情况。
days是另一个变量,是为了和测试周期的天数相对照,结果也不对,差别巨大。
您好,看下新版交易测评报告把。
交易次数:交易次数以平仓为判断标志。例:开仓1 手,加仓2 手,平仓3 手,则交易次数为1
次。开仓5 手,分5 次分别平仓1 手,则交易次数为5 次。