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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 当天盈利大于a则模型1第二天第三天都不交易如何写?

   

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


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

主题:当天盈利大于a则模型1第二天第三天都不交易如何写?

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


加好友 发短信
等级:论坛游侠 帖子:535 积分:0 威望:0 精华:0 注册:2015/3/23 12:33:01
当天盈利大于a则模型1第二天第三天都不交易如何写?  发帖心情 Post By:2016/3/8 20:32:58    Post IP:115.203.188.243[只看该作者]

有2个模型组合的策略如下,要求

若模型1当天盈利大于a则模型1第二天第三天都不交易(模型1连续休息二天,模型2仍开仓交易),

若模型2当天盈利大于b则模型2第二天第三天都不交易(模型2连续休息二天,模型1仍开仓交易),

若整个组合策略当天盈利大于c则整个策略第二天第三天都不交易(模型1模型2都连续休息2天都不开仓交易),如何写?

请老师直接把改写部分(以红字)加在如下组合策略中。谢谢

input:cang1(1,0,10,1),cang2(1,0,10,1);
variable:cc1=0,cc2=0;

/////////////////////////////////模型1——10周期反手
hi:=ref(hhv(h,10),1);
lo:=ref(llv(l,10),1);
if cc1>0 and l<lo then begin
 pc:=min(max(holding,0),cang1);
 kc:=cang1-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc1:=0;
end
if cc1<0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang1);
 kc:=cang1-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc1:=0;
end
if cc1=0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang1);
 kc:=cang1-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc1:=1;
end
if cc1=0 and l<lo then begin
 pc:=min(max(holding,0),cang1);
 kc:=cang1-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc1:=-1;
end

/////////////////////////////////以上是模型1

/////////////////////////////////模型2——20周期反手
hi:=ref(hhv(h,20),1);
lo:=ref(llv(l,20),1);
if cc2>0 and l<lo then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc2:=0;
end
if cc2<0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc2:=0;
end
if cc2=0 and h>hi then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc2:=1;
end
if cc2=0 and l<lo then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc2:=-1;
end

/////////////////////////////////以上是模型2


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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2016/3/9 9:51:16    Post IP:58.246.57.26[只看该作者]

input:cang1(1,0,10,1),cang2(1,0,10,1);
variable:cc1=0,cc2=0;

variable:bj=0;

/////////////////////////////////模型1——10周期反手
hi:=ref(hhv(h,10),1);
lo:=ref(llv(l,10),1);
if cc1>0 and l<lo and bj=0 then begin
 pc:=min(max(holding,0),cang1);
 kc:=cang1-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc1:=0;
end
if cc1<0 and h>hi and bj=0 then begin
 pc:=min(abs(min(holding,0)),cang1);
 kc:=cang1-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc1:=0;
end
if cc1=0 and h>hi  and bj=0 then begin
 pc:=min(abs(min(holding,0)),cang1);
 kc:=cang1-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc1:=1;
end
if cc1=0 and l<lo and bj=0 then begin
 pc:=min(max(holding,0),cang1);
 kc:=cang1-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc1:=-1;
end

yl:valuewhen(time=closetime(0),asset-ref(asset,todaybar));

yll:stkindi('','模型2.yl',0,datatype);

if time=closetime(0) and bj=0 then begin

    if yl>a then bj:=1;      

    if yl+yll>c then bj:=1;

end

 

bb:=valuewhen(bj=1 and ref(bj=0,1),barpos);

if barpos>bb+2*ref(todaybar,todaybar) and todaybar=1 then bj:=0;

 

 



金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2016/3/9 9:53:17    Post IP:58.246.57.26[只看该作者]

input:cang1(1,0,10,1),cang2(1,0,10,1);
variable:cc1=0,cc2=0;

variable:bj=0;

hi:=ref(hhv(h,20),1);
lo:=ref(llv(l,20),1);
if cc2>0 and l<lo and bj=0 then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc2:=0;
end
if cc2<0 and h>hi and bj=0 then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc2:=0;
end
if cc2=0 and h>hi and bj=0 then begin
 pc:=min(abs(min(holding,0)),cang2);
 kc:=cang2-pc;
 if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6);
 if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6);
 cc2:=1;
end
if cc2=0 and l<lo and bj=0 then begin
 pc:=min(max(holding,0),cang2);
 kc:=cang2-pc;
 if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6);
 if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6);
 cc2:=-1;
end

 

yl:valuewhen(time=closetime(0),asset-ref(asset,todaybar));

yll:stkindi('','模型1.yl',0,datatype);

if time=closetime(0) and bj=0 then begin

    if yl>b then bj:=1;      

    if yl+yll>c then bj:=1;

end

 

bb:=valuewhen(bj=1 and ref(bj=0,1),barpos);

if barpos>bb+2*ref(todaybar,todaybar) and todaybar=1 then bj:=0;

/////////////////////////////////以上是模型2



金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

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


加好友 发短信
等级:论坛游侠 帖子:535 积分:0 威望:0 精华:0 注册:2015/3/23 12:33:01
  发帖心情 Post By:2016/3/9 13:20:57    Post IP:115.203.171.34[只看该作者]

谢谢老师。
可能我没讲清楚,一楼的模型1与模型2组合成一个策略的,也就是说模是同一个策略里的二个组成部分。yl是整个策略的盈利yl>C,老师把模分拆成二个策略了。
请老师在同一个策略里修改。

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


加好友 发短信
等级:论坛游侠 帖子:535 积分:0 威望:0 精华:0 注册:2015/3/23 12:33:01
  发帖心情 Post By:2016/3/9 13:21:46    Post IP:115.203.171.34[只看该作者]

谢谢老师。
可能我没讲清楚,一楼的模型1与模型2组合成一个策略的,也就是说模型1与模型2是同一个策略里的二个组成部分。yl是整个策略的盈利yl>C,老师把模型1与模型2分拆成二个策略了。
请老师在同一个策略里修改。

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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2016/3/9 13:26:01    Post IP:58.246.57.26[只看该作者]

如果是两个策略就用上面的写

如果是一个策略则无法分清盈利情况



金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

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


加好友 发短信
等级:论坛游侠 帖子:535 积分:0 威望:0 精华:0 注册:2015/3/23 12:33:01
  发帖心情 Post By:2016/3/9 13:29:29    Post IP:115.203.171.34[只看该作者]

模型1(模型2)的当天盈利可否通过平仓价一开仓价来解决呢?

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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2016/3/9 13:31:49    Post IP:58.246.57.26[只看该作者]

你写在一起,开仓价平仓价分不清是第一部分还是第二部分的


金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

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


加好友 发短信
等级:论坛游侠 帖子:535 积分:0 威望:0 精华:0 注册:2015/3/23 12:33:01
  发帖心情 Post By:2016/3/9 14:24:38    Post IP:115.203.171.34[只看该作者]

哦,谢谢老师。

 

強大的金字塔也难住了。


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


加好友 发短信
等级:黑侠 帖子:625 积分:0 威望:0 精华:0 注册:2015/12/28 12:24:59
  发帖心情 Post By:2016/3/9 15:40:52    Post IP:125.104.240.144[只看该作者]

 请问老师如果模型1当天盈利大于a,第二天不休息继续交易只是自动由实盘帐户如123456#转为模拟帐户如600888#,怎么写?

 回到顶部
总数 11 1 2 下一页