这个是测试结果 测试时间选的是 04年至12年。
1.但是3个品种的测试截止日期分别是在 08年 09年 停止下来了。虽然CU 里面可能剩余资金不多 但是C 和CF 应该还是有所剩余的 但是不知道为什么 后面却不交易了。
是否是数据有问题?
2.请问 如果是基于日线进行测试的话 在交易系统评测中 选择怎样的选项比较贴近实际?
测试品种为 郑棉 连续 玉米连续 铜连续 测试时间为2004年7月1日 至今。
保证金比例为10%
交易手续费为 :单向 C 10 CF 20 CU 40
附上测试代码
新建技术指标 HL: 参数VDAYS 取值为10
顺便请问版主 以下几个指标 是否并非未来函数?就是说 这些应该只会取到前一天的数据?引用方式请见下面代码
HIGH20:REF(HHV(HIGH,VDAYS),1);
LOW20:REF(LLV(LOW,VDAYS),1);
ATR20:ema(ref(tr,1),20);
新建交易系统:测试海龟
以下代码 改变自和风海龟。
input:inb(20,1,500,1),outb(10,1,500,1),risk(0,0,10,0.1);
variable:times=0,i=0,n=0;
ATR20:="HL.ATR20#DAY";//20日真实波幅
HIGH20:="HL.HIGH20#DAY";// MA20日
LOW20:="HL.LOW20#DAY";// MA20日
n:=valuewhen(holding=0,ATR20);
//rh:=ref(h,1);
//rl:=ref(l,1);
//h1:hhv(rh,inb);
//h2:hhv(rh,outb),linedot;
//l1:llv(rl,inb);
//l2:llv(rl,outb),linedot;
lotst:asset*risk*0.01/(n*2*multiplier),linethick0;
lots:=if(risk=0,1,lotst); //如果risk取0,表示固定开1手
maxstc:=1; //仓位不能超过当前资产20% 是否可以考虑用 floor (assets *0.2)
tbc:=h<>l;//判断是否停板
if holding=0 and tbc then //不是停板才可以交易
begin
if H>HIGH20 then //开多
begin
buyp:=max(o,h);
buy(1,lots,limitr,buyp);
times:=1;
while h>enterprice+n*0.5 and times<1 do
begin
buyp:=max(o,enterprice+n*0.5);
buy(1,lots,limitr,buyp);
times:=times+1;
end;//连续开仓
end;//开多结束
else if LOW<LOW20 then //开空
begin
sellp:=min(o,l);
buyshort(1,lots,limitr,sellp);
times:=1;
while LOW<enterprice-n*0.5 and times<1 do
begin
sellp:=min(o,enterprice-n*0.5);
buyshort(1,lots,limitr,sellp);
times:=times+1; //times 暂时无用 以后可能会用 先留着吧。
end;//连续开仓
end;
end;//holding=0
if holding>0 and tbc then //已有多仓 while部分由于资金量少 所以没准备让他做太多处理
begin
exitlongp:=max(enterprice-2*n,l);
if LOW<exitlongp and enterbars>0 then //出场
begin
exitp:=min(o,exitlongp);
sell(1,0,limitr,exitp);
times:=0;
end;//出场
else
begin
while h>enterprice+n*0.5 and times<2 and abs(holding)<maxstc do //开多只加1手 仓位不能超过资产的20%
begin
buyp:=max(h,enterprice+n*0.5);
buy(1,lots,limitr,buyp);
times:=times+1;
end;//连续开仓
end;//else
end;//holding>0
if holding<0 and tbc then //已有空仓
begin
exitlongp:=min(enterprice+2*n,h);
if h>exitlongp and enterbars<>0 then //出场
begin
exitp:=max(o,exitlongp);
sellshort(1,0,limitr,exitp);
times:=0;
end;//出场
else
begin
while l<enterprice-n*0.5 and times<2 and abs(holding)<maxstc do //开空 只加1手 仓位不能超过资产的20%
begin
sellp:=min(l,enterprice-n*0.5);
buyshort(1,lots,limitr,sellp);
times:=times+1;
end;//连续开仓
end;//else
end;//holding<0
[此贴子已经被作者于2012-2-17 0:13:05编辑过]
这个不靠谱的 这个公式在 文华上跑的顺溜的很。。。 毕竟只是测试海龟 价格不可能连 10日内高低点都突破不了。 突破了就构成平仓条件
在交易费用一栏,勾选使用系统预设品种费率,一切正常。