以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  公式求助!  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=160792)

--  作者:2017gogogoo
--  发布时间:2018/1/2 10:09:48
--  公式求助!

请问我用图表做高频,为了防止平仓信号出现时还没有收到成交回报而出现的平仓无法执行的情况(开平经常在同一秒),我加上下面这段语句来辅助平仓是否可行?请帮忙解答。

 

if holding=0 and tholding>0 then begin
 buy(BARPOS=1,ss,THISCLOSE);
 sell(1,holding,marketr);
 end


--  作者:wenarm
--  发布时间:2018/1/2 10:17:51
--  

不行,而且这种会造成你信号闪烁的。

这种精细化的控制,建议你用后台程序化完成。


--  作者:FireScript
--  发布时间:2018/1/2 10:32:59
--  

先说tholding 的问题是:历史K上是没有值的,只在最新K有值。也就是说buy语句是不会执行的。因为你buy还有一个barpos=1的条件在里面。

 

此外就是想在图表判断实际下单情况是不行的,无法做到的。

开平语句的条件上最好能互斥和独立。必须在条件上让开仓和平仓存在一定时间差。

 


--  作者:2017gogogoo
--  发布时间:2018/1/2 10:52:26
--  
以下是引用FireScript在2018/1/2 10:32:59的发言:

先说tholding 的问题是:历史K上是没有值的,只在最新K有值。也就是说buy语句是不会执行的。因为你buy还有一个barpos=1的条件在里面。

 

此外就是想在图表判断实际下单情况是不行的,无法做到的。

开平语句的条件上最好能互斥和独立。必须在条件上让开仓和平仓存在一定时间差。

 

谢谢回复,我是半自动程序化,有时候手动开仓,让程序化平仓,不在乎信号闪烁的;如果说tholding在历史k线上没有值的话,那我这样改一下是否可行?

 

if holding=0 and tholding>0 then begin
 buy(1,ss,THISCLOSE);
 sell(1,holding,marketr);
 end         
如果不行,怎么改呢?麻烦了


--  作者:2017gogogoo
--  发布时间:2018/1/2 10:57:01
--  

金字塔图表交易的话好像同一根k线上只执行一次开仓信号,那这样写应该没问题吧?

 


--  作者:2017gogogoo
--  发布时间:2018/1/2 10:59:06
--  

 

请帮忙确认一下下面的buy到底能不能被执行,我看别人的帖子好像没问题啊?

if holding=0 and tholding>0 then begin
 buy(BARPOS=1,ss,THISCLOSE);
 sell(1,holding,marketr);
 end


--  作者:wenarm
--  发布时间:2018/1/2 11:01:34
--  

同一个开仓语句在一根k线只会开一次。

 

你可以在开平语句后加ORDERQUEUE


--  作者:2017gogogoo
--  发布时间:2018/1/2 11:17:06
--  
以下是引用wenarm在2018/1/2 11:01:34的发言:

同一个开仓语句在一根k线只会开一次。

 

你可以在开平语句后加ORDERQUEUE

1,谢谢wenarm版主,能不能帮我解答下6楼的问题是否可行?

2,如果用ORDERQUEUE的话,对公式的执行效率是否有影响?谢谢了


--  作者:FireScript
--  发布时间:2018/1/2 11:32:06
--  

1.6楼那个不行,tholding不要用在图表上。

 

2.ORDERQUEUE只是下单强制要求按照一个下单序列来进行, 不会对效率产生多大影响。建议只把需要的下单语句使用这个函数。


--  作者:2017gogogoo
--  发布时间:2018/1/2 13:25:28
--  

谢谢版主,我对orderqueue这个函数不熟悉,函数说明解释的也不是太清楚,请看下我这样用orderqueue修改公式是否正确?是否就能防止平仓信号出现时还没有收到成交回报而出现的平仓无法执行的情况出现?

 

原代码:

input:ss(2,1,999,1),p(0,0,400000,1),wt(0,-20,20,1),xdpy(3,0,10,1);
VARIABLE:cfT=0,CFP=0,eckcON=0;//eckcON为二次开仓开关。
istoday:=date[DATACOUNT]=date;
hh:if(istoday and cfT=0 and p<>0,p,drawnull),LINETHICK2,COLORRED;
hhh:if(istoday AND cfP=0 and wt<>0 and eckcON=1,p+wt*mindiff,drawnull),LINETHICK2,COLORRED;
xdj:if(istoday and p<>0,p+(wt+xdpy)*mindiff,drawnull),LINEDOT,COLORBROWN;


//开多
if  h>=hh then begin
 if o<=hh and holding=0 then BEGIN 
  buy(1,ss,limitr,xdj);
 end
 cfT:=1;
end

if h>=hhh then begin
 if o<=hhh and holding=0 and eckcON=1 then BEGIN 
  buy(1,ss,limitr,xdj);
 end  
 if h>hhh then cfP:=1;
end


 
//止损
if  holding>0 and c<>h then begin
 sell(1,holding,marketr);
 eckcON:=1;
end


if holding=0 and tholding>0 then begin
 buy(BARPOS=1,ss,THISCLOSE);
 sell(1,holding,marketr);
 end

 

修改后:

input:ss(2,1,999,1),p(0,0,400000,1),wt(0,-20,20,1),xdpy(3,0,10,1);
VARIABLE:cfT=0,CFP=0,eckcON=0;//eckcON为二次开仓开关。
istoday:=date[DATACOUNT]=date;
hh:if(istoday and cfT=0 and p<>0,p,drawnull),LINETHICK2,COLORRED;
hhh:if(istoday AND cfP=0 and wt<>0 and eckcON=1,p+wt*mindiff,drawnull),LINETHICK2,COLORRED;
xdj:if(istoday and p<>0,p+(wt+xdpy)*mindiff,drawnull),LINEDOT,COLORBROWN;


//开多
if  h>=hh then begin
 if o<=hh and holding=0 then BEGIN 
  buy(1,ss,limitr,xdj),orderqueue;
 end
 cfT:=1;
end

if h>=hhh then begin
 if o<=hhh and holding=0 and eckcON=1 then BEGIN 
  buy(1,ss,limitr,xdj),orderqueue;
 end  
 if h>hhh then cfP:=1;
end


 
//止损
if  holding>0 and c<>h then begin
 sell(1,holding,marketr),orderqueue;
 eckcON:=1;
end

 

请问orderqueue用法对吗?这样修改可以达到目的吗?谢谢了