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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件策略编写求助区 → [求助][讨论]股指日内交易

   

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


  共有5894人关注过本帖树形打印复制链接

主题:[求助][讨论]股指日内交易

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


加好友 发短信
等级:论坛游民 帖子:262 积分:2802 威望:0 精华:0 注册:2011/11/17 19:20:51
  发帖心情 Post By:2012/2/11 22:59:27 [显示全部帖子]

我给过你类似的模型,结果不好。再有为什么要限制交易次数?这在策略设计时是没有道理的。

variable:a1=0;

r1:=barslast(day-ref(day,1)<>0);

r2:ref(o,r1);

r3:r2+10;

r4:r2-10;

r5:=time>091500 and time<151000;

if cross(h,r2) and r5 and holding=0 and a1=0 then

     begin

     buy(1,1,limitr,r3)

     end

if cross(r4,l) and r5 and holding=0 and a1=0 then

     begin

     buyshort(1,1,limitr,r4);

     end

if holding>0 and cross(r4,l) and r5 then

     begin

     sell(1,0,limitr,r4);

     a1:=1;

     end

if holding<0 and cross(h,r3) and r5 then

     begin

     sellshort(1,0,limitr,r3);

     a1:=1;

     end

if time>=151000 and holding<>0 then

     begin

     sell(holding>0,0,thisclose);

     sellshort(holding<0,0,thisclose);

     a1:=1;

     end

以上的代码用于测试,实际交易时用如下代码:

variable:a1=0;

r1:=barslast(day-ref(day,1)<>0);

r2:ref(o,r1);

r3:r2+10;

r4:r2-10;

r5:=time>091500 and time<151000;

if cross(c,r2) and r5 and holding=0 and a1=0 then

begin

buy(1,1,limitr,r3)

end

if cross(r4,c) and r5 and holding=0 and a1=0 then

begin

buyshort(1,1,limitr,r4);

end

if holding>0 and cross(r4,c) and r5 then

begin

sell(1,0,limitr,r4);

a1:=1;

end

if holding<0 and cross(c,r3) and r5 then

begin

sellshort(1,0,limitr,r3);

a1:=1;

end

if time>=151000 and holding<>0 then

begin

sell(holding>0,0,thisclose);

sellshort(holding<0,0,thisclose);

a1:=1;

end

以上代码没有测试,估计不会有大问题,


 回到顶部
帅哥哟,离线,有人找我吗?
zg611029
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:262 积分:2802 威望:0 精华:0 注册:2011/11/17 19:20:51
  发帖心情 Post By:2012/2/11 23:11:02 [显示全部帖子]

我理解你限制明天只交易一次,是为了抓单边市。如果这样你用SAR的思路可能更好。试试看吧

 


 回到顶部
帅哥哟,离线,有人找我吗?
zg611029
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:262 积分:2802 威望:0 精华:0 注册:2011/11/17 19:20:51
  发帖心情 Post By:2012/2/12 14:57:40 [显示全部帖子]

把你的思路改了一下,下面的代码可以实用,长期使用肯定亏不了钱,但也赚不了大钱。建议用5分钟周期

 

 

 

//股指期货自动交易程序
//编制:zg611029 qq:2313936161

input:n(13,5,30,1);

//交易手数:
tn:=1;

r1:=barslast(day-ref(day,1)<>0);

r5:ref(o,r1);
r6:r5+n;
r7:r5-n;

if cross(h,r6)  then
 begin
 buy(holding=0,tn,limitr,r6);
 end
if cross(r7,l) then
 begin
 buyshort(holding=0,tn,limitr,r7);
 end
if holding>0 and cross(r5,l) then
 begin
 sell(1,0,limitr,r5);
 end
if holding<0 and cross(h,r5) then
 begin
 sellshort(1,0,limitr,r5);
 end
  
//收盘前清仓
if time>=151400 then
 begin
 sellshort(holding<0,0,thisclose);
 sell(holding>0,0,thisclose);
 end
 
持仓:holding,colorwhite,linethick0;
交易总数:totaltrade,colorwhite,linethick0;
盈亏:asset-1000000,noaxis,colorred,linethick1;


 


 回到顶部