欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 后台模板套入后的问题

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有7046人关注过本帖平板打印复制链接

主题:后台模板套入后的问题

帅哥哟,离线,有人找我吗?
eric917
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:271 积分:730 威望:0 精华:0 注册:2011/6/22 15:58:05
后台模板套入后的问题  发帖心情 Post By:2013/2/26 11:28:39    Post IP:58.246.57.26[只看该作者]

环境介绍:

//运行周期:1分钟

//运行模式:固定时间间隔,1秒轮询 

//运行品种:IF1303

 

会多个策略对改品种下单,希望各策略的开平仓独立,每个策略管好自己的开平仓 

系统很简单,就是最高价突破均线平空开多,最低价突破平多开空,每根K线都只开平一次,开仓后当根K线后面的信号可以忽略

 

 

利用火哥的模板http://www.weistock.com/bbs/dispbbs.asp?boardid=10&id=9112

蓝色为测试的图表交易系统:

globalvariable:hold=drawnull;

//以下为系统内容
ss:=1; //手数
//variable:myenterbars=0;

maa:ema(c,10);
tt1:=h>maa;
tt2:=l<maa;
//当开始没有持仓
if  holding=0 then begin
     if tt1 then  begin
         buy(1,ss,market)
         goto continueline;
     end
    
     if tt2 then begin
        buyshort(1,ss,market);
        goto continueline;
     end
end

if tt1 and  holding<0 and  enterbars>=0 then begin
     sellshort(1,ss,market);
     buy(1,ss,market);
     goto continueline;
end

if tt2 and  holding>0 and  enterbars>=0 then begin
     sell(1,ss,market);
     buyshort(1,ss,market);
     goto continueline;
end

continueline@ 资产:tasset,linethick0;
aa-tt:if(tt1,1,if(tt2,-1,0)),nodraw;
bb-holding:holding,nodraw;
cc-enterbars:enterbars,nodraw;

//以上为模型内容

 

cc803555:=holding;//这句放在信号稳定的地方

drawtextex(1,1,800,0,'虚拟持仓为:'+numtostr(cc803555,0));//在图表上输入虚拟持仓以便监控
if not(islastbar) or workmode<>1 then exit;


xiadan803555:=cc803555-hold;
if xiadan803555>0.5 then begin
cang:=min(xiadan803555,abs(hold));


if hold<0 then begin
tsellshort(1,cang,mkt,0,0,'803555'),allowrepeat;
debugfile('d:\803555.txt',numtostr(hold,0)+' '+numtostr(cc803555,0)+' 平空 %.0f',cang);
end
cang:=xiadan803555+min(hold,0);


if cang>0 then begin
tbuy(1,cang,mkt,0,0,'803555'),allowrepeat;
debugfile('d:\803555.txt',numtostr(hold,0)+' '+numtostr(cc803555,0)+' 开多 %.0f',cang);
end
end
if xiadan803555<-0.5 then begin
cang:=min(abs(xiadan803555),abs(hold));
if hold>0 then begin
tsell(1,cang,mkt,0,0,'803555'),allowrepeat;
debugfile('d:\803555.txt',numtostr(hold,0)+' '+numtostr(cc803555,0)+' 平多 %.0f',cang);
end


cang:=abs(xiadan803555)-max(hold,0);
if cang>0 then begin
tbuyshort(1,cang,mkt,0,0,'803555'),allowrepeat;
debugfile('d:\803555.txt',numtostr(hold,0)+' '+numtostr(cc803555,0)+' 开空 %.0f',cang);
end
end
hold:=cc803555;

 

运行环境:(1手单)1分钟 IF1303 逐K模式  账号为虚拟账号

图表系统单独运行,测试正常

套入后台模板后,有几个问题:

1)单账号没有持仓的时候,交易正常

2)当我手动将账号调成2手多头2手空头同时持有,再加载这个后台系统,系统开始只会把其中的一手空仓或者多仓做反手(就是系统一直都是持有4手单),总单量没变

3)之前在图表加载的时候,一根K线只会执行一次开平仓,但套入后套模板后,却会在同一K线出现多次开平仓(不知道是不是因为模板里面的allowrepeat函数问题),

     请问是否将其去除就不会出现多次开平仓的问题?

 

 


 回到顶部