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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件交易策略发布专区 → 把不同模型组合成一个模型的范例

   

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


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

主题:把不同模型组合成一个模型的范例

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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
把不同模型组合成一个模型的范例  发帖心情 Post By:2011/9/13 15:54:59 [只看该作者]

经常碰到塔友有类似的问题,现举个简单的例子

 

variable:cc1=0,cc2=0;
//第一个模型,大于上10周期最高价买入,低于5周期最低价平仓。做空反之
//第二个模型,连续2根K线收阳线买入,做空反之
//用于测试使用。如果实盘,需用专业版的后台,因为可能同一根K线图产生2个同向信号
//或者信号相反时持仓对冲的处理。
yl:=ref(hhv(h,10),1);
zc:=ref(llv(l,10),1);
yl1:=ref(hhv(h,5),1);
zc1:=ref(llv(l,5),1);
b2:=ref(c>o,1) and ref(c>o,2);
s2:=ref(c<o,1) and ref(c<o,2);

/////////////////////////////////////////第二个模型是开盘价触发,写在最前面
if cc2>0 and s2 then begin
 cc2:=0;
 if holding>0 then sell(1,1,limitr,o);
 else buyshort(1,1,limitr,o);
end

if cc2<0 and b2 then begin
 cc2:=0;
 if holding<0 then sellshort(1,1,limitr,o);
 else buy(1,1,limitr,o);
end

if cc2=0 and b2 then begin
 cc2:=1;
 if holding<0 then sellshort(1,1,limitr,o);
 else buy(1,1,limitr,o);
end

if cc2=0 and s2 then begin
 cc2:=-1;
 if holding>0 then sell(1,1,limitr,o);
 else buyshort(1,1,limitr,o);
end
////////////////////////////////////////////////////////////////////////////////////////
if cc1>0 and l<zc1 then begin
 cc1:=0;
 if holding>0 then sell(1,1,limitr,min(o,zc1-mindiff));
 else buyshort(1,1,limitr,min(o,zc1-mindiff));
end

if cc1<0 and h>yl1 then begin
 cc1:=0;
 if holding<0 then sellshort(1,1,limitr,max(o,yl1+mindiff));
 else buy(1,1,limitr,max(o,yl1+mindiff));
end


if cc1=0 and h>yl then begin
 cc1:=1;
 if holding<0 then sellshort(1,1,limitr,max(o,yl+mindiff));
 else buy(1,1,limitr,max(o,yl+mindiff));
end

if cc1=0 and l<zc then begin
 cc1:=-1;
 if holding>0 then sell(1,1,limitr,min(o,zc-mindiff));
 else buyshort(1,1,limitr,min(o,zc-mindiff));
end


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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2011/9/13 19:49:20 [只看该作者]

怎么跑到策略发布区了?

这是不同模型组合的模板,碰到仓位相反时,会对冲仓位,实盘时可节约资金、减少手续费。

[此贴子已经被作者于2011-9-13 19:50:42编辑过]

 回到顶部