以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  金字塔软件问题提交  (http://weistock.com/bbs/list.asp?boardid=2)
----  [求助]公式测评和模拟操作的下单手数为什么不一样?  (http://weistock.com/bbs/dispbbs.asp?boardid=2&id=70459)

--  作者:jiaweiharry
--  发布时间:2014/9/25 23:25:11
--  [求助]公式测评和模拟操作的下单手数为什么不一样?

求助老师,我用同样的资金1000万,同样的时间2014年9月25日,周期1分钟,但是为什么测评的时候每次下单手数是一两百手,而今天我跑了一天模拟盘每次下单手数只有一二十手?这样直接导致了测试出来的收益和实际自动交易的收益差了近十倍啊!求问老师是代码的问题,还是测评和模拟盘操作原理不一样?

策略是海龟交易策略。这是源码:

input:inb(20,1,500,1),outb(10,1,500,1),risk(2,0,10,0.1);
//和风版海龟源码
variable:times=0,i=0,n=0;
rn:=ema(ref(tr,1),20);
n:=valuewhen(holding=0,rn);
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手
tbc:=h<>l;//判断是否停板
partline(holding>0,enterprice-2*n);
if barpos<inb+1 then exit;
if holding=0 and tbc then //不是停板才可以交易
begin
if h>h1 then //开多
begin
buyp:=max(o,h1);
buy(1,lots,limitr,buyp);
times:=1;
while h>enterprice+n*0.5 and times<4 do
begin
buyp:=max(o,enterprice+n*0.5);
buy(1,lots,limitr,buyp);
times:=times+1;
end;//连续开仓
end;//开多结束
else if l<l1 then //开空
begin
sellp:=min(o,l1);
buyshort(1,lots,limitr,sellp);
times:=1;
while l<enterprice-n*0.5 and times<4 do
begin
sellp:=min(o,enterprice-n*0.5);
buyshort(1,lots,limitr,sellp);
times:=times+1;
end;//连续开仓
end;
end;//holding=0

if holding>0 and tbc then //已有多仓
begin
exitlongp:=max(enterprice-2*n,l2);
if l<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<4 do //开多
begin
buyp:=max(o,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,h2);
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<4 do //开多
begin
sellp:=min(o,enterprice-n*0.5);
buyshort(1,lots,limitr,sellp);
times:=times+1;
end;//连续开仓
end;//else
end;//holding<0
谢谢老师啦!


--  作者:jiaweiharry
--  发布时间:2014/9/25 23:30:27
--  
测试品种是股指
--  作者:FexTel
--  发布时间:2014/9/26 8:53:48
--  

图表是先依据公式里面的虚拟资金开仓,把虚拟自己也调成1000w

 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20140926085311.png
图片点击可在新窗口打开查看

--  作者:yukizzc
--  发布时间:2014/9/26 8:54:19
--  

图表虚拟资金也是1000w?

你在图上输出lots看下这个值是多少


--  作者:jiaweiharry
--  发布时间:2014/9/26 20:04:20
--  
谢谢老师!那请问我以后如果用1万资金的话,是不是也把公式费率设置的虚拟资金改为1万?
以下是引用FexTel在2014/9/26 8:53:48的发言:

图表是先依据公式里面的虚拟资金开仓,把虚拟自己也调成1000w

 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20140926085311.png
图片点击可在新窗口打开查看


--  作者:FexTel
--  发布时间:2014/9/28 21:49:53
--  
是的,开仓百分比是依据当前资金asset来的。对应会根据设置的初始资金