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


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

   

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


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

主题:请教老师公式问题

帅哥哟,离线,有人找我吗?
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;

 回到顶部
帅哥哟,离线,有人找我吗?
xwxlmb
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | 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;

 



 回到顶部
帅哥哟,离线,有人找我吗?
xwxlmb
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | 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日低点止损或止盈,不加仓。

 回到顶部
帅哥哟,离线,有人找我吗?
xwxlmb
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | 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;

 

 回到顶部
帅哥哟,离线,有人找我吗?
xwxlmb
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | 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[显示全部帖子]

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

 回到顶部