请问我用图表做高频,为了防止平仓信号出现时还没有收到成交回报而出现的平仓无法执行的情况(开平经常在同一秒),我加上下面这段语句来辅助平仓是否可行?请帮忙解答。
if holding=0 and tholding>0 then begin
buy(BARPOS=1,ss,THISCLOSE);
sell(1,holding,marketr);
end
不行,而且这种会造成你信号闪烁的。
这种精细化的控制,建议你用后台程序化完成。
先说tholding 的问题是:历史K上是没有值的,只在最新K有值。也就是说buy语句是不会执行的。因为你buy还有一个barpos=1的条件在里面。
此外就是想在图表判断实际下单情况是不行的,无法做到的。
开平语句的条件上最好能互斥和独立。必须在条件上让开仓和平仓存在一定时间差。
先说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 如果不行,怎么改呢?麻烦了
金字塔图表交易的话好像同一根k线上只执行一次开仓信号,那这样写应该没问题吧?
请帮忙确认一下下面的buy到底能不能被执行,我看别人的帖子好像没问题啊?
if holding=0 and tholding>0 then begin
buy(BARPOS=1,ss,THISCLOSE);
sell(1,holding,marketr);
end
同一个开仓语句在一根k线只会开一次。
你可以在开平语句后加ORDERQUEUE
同一个开仓语句在一根k线只会开一次。
你可以在开平语句后加ORDERQUEUE
1,谢谢wenarm版主,能不能帮我解答下6楼的问题是否可行?
2,如果用ORDERQUEUE的话,对公式的执行效率是否有影响?谢谢了
1.6楼那个不行,tholding不要用在图表上。
2.ORDERQUEUE只是下单强制要求按照一个下单序列来进行, 不会对效率产生多大影响。建议只把需要的下单语句使用这个函数。
谢谢版主,我对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用法对吗?这样修改可以达到目的吗?谢谢了