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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 请教老师公式问题

   

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


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

主题:请教老师公式问题

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


加好友 发短信
等级:新手上路 帖子:20 积分:0 威望:0 精华:0 注册:2016/5/15 8:59:02
请教老师公式问题  发帖心情 Post By:2016/5/17 9:19:38    Post IP:113.103.177.198[只看该作者]

请教老师,如何添加命令使程序在空仓状态下,系统发出开仓指令一次性执行定义的持仓量,并忽略平仓前的其它开仓信号。 input:inb(20,1,20,1),outb(10,1,20,1),risk(1,0,10,0.1); //海龟源码 variable:times=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); l1:llv(rl,inb); l2:llv(rl,outb); lotst:asset*risk*0.01/(n*multiplier); lots:=if(risk=0,1,lotst); //如果risk取0,表示固定开1手 tbc:=h<>l;//判断是否停板 if holding=0 and tbc then //不是停板才可以交易 begin if h>h1 then //开多 begin buyp:=max(o,h1); buy(1,lots,limitr,buyp); end;//开多结束 else if l<l1 then //开空 begin sellp:=min(o,l1 ); buyshort(1,lots,limitr,sellp); end;//开空结束 if holding>0 and tbc then //已有多仓 begin exitlongp:=max(enterprice,l2); if l<exitlongp and enterbars<>0 then //出场 begin exitp:=min(o,exitlongp); sell(1,0,limitr,exitp); end;//出场 if holding<0 and tbc then //已有空仓 begin exitlongp:=min(enterprice,h2); if h>exitlongp and enterbars<>0 then //出场 begin exitp:=max(o,exitlongp); sellshort(1,0,limitr,exitp); end;//出场 end; end; end;

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


加好友 发短信
等级:新手上路 帖子:20 积分:0 威望:0 精华:0 注册:2016/5/15 8:59:02
  发帖心情 Post By:2016/5/17 9:22:23    Post IP:113.103.177.198[只看该作者]

请教老师,如何添加命令使程序在空仓状态下,系统发出开仓指令一次性执行定义的持仓量,并忽略平仓前的其它开仓信号。 input:inb(20,1,20,1),outb(10,1,20,1),risk(1,0,10,0.1); //海龟源码 variable:times=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); l1:llv(rl,inb); l2:llv(rl,outb); lotst:asset*risk*0.01/(n*multiplier); lots:=if(risk=0,1,lotst); //如果risk取0,表示固定开1手 tbc:=h<>l;//判断是否停板 if holding=0 and tbc then //不是停板才可以交易 begin if h>h1 then //开多 begin buyp:=max(o,h1); buy(1,lots,limitr,buyp); end;//开多结束 else if l<l1 then //开空 begin sellp:=min(o,l1 ); buyshort(1,lots,limitr,sellp); end;//开空结束 if holding>0 and tbc then //已有多仓 begin exitlongp:=max(enterprice,l2); if l<exitlongp and enterbars<>0 then //出场 begin exitp:=min(o,exitlongp); sell(1,0,limitr,exitp); end;//出场 if holding<0 and tbc then //已有空仓 begin exitlongp:=min(enterprice,h2); if h>exitlongp and enterbars<>0 then //出场 begin exitp:=max(o,exitlongp); sellshort(1,0,limitr,exitp); end;//出场 end; end; end;

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


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

用IE发帖,然后格式发的准确一点


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

客户服务部

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

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

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


加好友 发短信
等级:新手上路 帖子:20 积分:0 威望:0 精华:0 注册:2016/5/15 8:59:02
  发帖心情 Post By:2016/5/17 9:29:58    Post IP:113.103.177.198[只看该作者]


input:inb(20,1,20,1),outb(10,1,20,1),risk(1,0,10,0.1); 
//海龟源码 
variable:times=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); 
l1:llv(rl,inb); 
l2:llv(rl,outb); 
lotst:asset*risk*0.01/(n*multiplier); 
lots:=if(risk=0,1,lotst); //如果risk取0,表示固定开1手 
tbc:=h<>l;//判断是否停板 if holding=0 and tbc then //不是停板才可以交易 
begin 
if h>h1  then //开多 
begin 
buyp:=max(o,h1); 
buy(1,lots,limitr,buyp); 
end;//开多结束
else if l<l1  then //开空 
begin 
sellp:=min(o,l1 ); 
buyshort(1,lots,limitr,sellp);
end;//开空结束
if holding>0 and tbc then //已有多仓 
begin 
exitlongp:=max(enterprice,l2); 

if l<exitlongp and enterbars<>0 then //出场 
begin 
exitp:=min(o,exitlongp); 
sell(1,0,limitr,exitp); 
end;//出场 

if holding<0 and tbc then //已有空仓 
begin 
exitlongp:=min(enterprice,h2); 
if h>exitlongp and enterbars<>0 then //出场 
begin 
exitp:=max(o,exitlongp); 
sellshort(1,0,limitr,exitp); 
end;//出场
end;
end;
end;

 



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


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

系统发出开仓指令一次性执行定义的持仓量,并忽略平仓前的其它开仓信号

这句指的是什么情况?



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

客户服务部

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

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

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


加好友 发短信
等级:新手上路 帖子:20 积分:0 威望:0 精华:0 注册:2016/5/15 8:59:02
  发帖心情 Post By:2016/5/17 9:37:12    Post IP:113.103.177.198[只看该作者]

老师您试一下,开仓量被分成多次执行了,我想空仓状态第一次出信号开仓,如突破前20日高点开仓,反向2ATR止损、反向前10日低点止损或止盈,不加仓。

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


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

海龟就是有多次加仓的,你想要不加仓,在开仓语句里面加上holding=0的判断


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

客户服务部

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

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

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


加好友 发短信
等级:新手上路 帖子:20 积分:0 威望:0 精华:0 注册:2016/5/15 8:59:02
  发帖心情 Post By:2016/5/17 9:57:03    Post IP:113.103.177.198[只看该作者]

老师这样改对吗?
input:inb(20,1,20,1),outb(10,1,20,1),risk(1,0,10,0.1); 
//海龟源码 
variable:times=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); 
l1:llv(rl,inb); 
l2:llv(rl,outb); 
lotst:asset*risk*0.01/(n*multiplier); 
lots:=if(risk=0,1,lotst); //如果risk取0,表示固定开1手 
tbc:=h<>l;//判断是否停板 if holding=0 and tbc then //不是停板才可以交易 
begin 
if h>h1  then //开多 
begin 
buyp:=max(o,h1); 
buy(1,lots,limitr,buyp); 
end;//开多结束
else if l<l1  then //开空 
begin 
sellp:=min(o,l1 ); 
buyshort(1,lots,limitr,sellp);
end;//开空结束
if holding=0 and tbc then //已有多仓 
begin 
exitlongp:=max(enterprice,l2); 

if l<exitlongp and enterbars<>0 then //出场 
begin 
exitp:=min(o,exitlongp); 
sell(1,0,limitr,exitp); 
end;//出场 

if holding=0 and tbc then //已有空仓 
begin 
exitlongp:=min(enterprice,h2); 
if h>exitlongp and enterbars<>0 then //出场 
begin 
exitp:=max(o,exitlongp); 
sellshort(1,0,limitr,exitp); 
end;//出场
end;
end;
end;

 

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


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

buy(1,lots,limitr,buyp); 
buyshort(1,lots,limitr,sellp);
 
这两句改成
 
buy(holding=0,lots,limitr,buyp); 
buyshort(holding=0,lots,limitr,sellp);
其他不要改
 
 


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

客户服务部

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

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

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


加好友 发短信
等级:新手上路 帖子:20 积分:0 威望:0 精华:0 注册:2016/5/15 8:59:02
  发帖心情 Post By:2016/5/17 10:06:11    Post IP:113.103.177.198[只看该作者]

感谢老师的指导!下班试试。

 回到顶部