问题是这样的,我希望在后台完成套利
bb 和ss 分别是触发条件
if bb then begin
tsellshort(1,1,lmt,远期卖一+3,0,'802089','zjif09'),orderqueue;
tsell(1,1,lmt,近期买一-3,0,'802089','zjif05'),orderqueue;
tbuy(1,1,lmt,远期卖一+3,0,'802089','zjif09'),orderqueue;
tbuyshort(1,1,lmt,近期买一-3,0,'802089','zjif05'),orderqueue;
end
if ss then begin
tsell(1,1,lmt,远期买一-3,0,'802089','zjif09'),orderqueue;
tsellshort(1,1,lmt,近期卖一+3,0,'802089','zjif05'),orderqueue;
tbuyshort(1,1,lmt,远期买一-3,0,'802089','zjif09'),orderqueue;
tbuy(1,1,lmt,近期卖一+3,0,'802089','zjif05'),orderqueue;
end
即bb触发后,就执行bb的4个语句,反之在ss触发之后完成ss的4步动作。
现在这样情况下bb和ss的动作都是正常,也就是说条件本身是可以出现交易的。
但是我希望bb之后出现的bb 不再出现动作,即bb之后,4步工作完成后,不动作,一直等到ss出现再进行ss的动作。
ss同理,即ss出现后再出现的ss不动作,直到bb出现再工作。简单的说就是再后台使用类似tfilter函数的功能。
为了完成进行如下设计:
variable:a:=0;
if a>0 and ss then begin
tsellshort(1,1,lmt,远期卖一+3,0,'802089','zjif09'),orderqueue;
tsell(1,1,lmt,近期买一-3,0,'802089','zjif05'),orderqueue;
a:=0;
end
if a<0 and bb then begin
tsell(1,1,lmt,远期买一-3,0,'802089','zjif09'),orderqueue;
tsellshort(1,1,lmt,近期卖一+3,0,'802089','zjif05'),orderqueue;
a:=0;
end
if a=0 and bb then begin
tbuy(1,1,lmt,远期卖一+3,0,'802089','zjif09'),orderqueue;
tbuyshort(1,1,lmt,近期买一-3,0,'802089','zjif05'),orderqueue;
a:=1;
end
if a=0 and ss then begin
tbuyshort(1,1,lmt,远期买一-3,0,'802089','zjif09'),orderqueue;
tbuy(1,1,lmt,近期卖一+3,0,'802089','zjif05'),orderqueue;
a:=-1;
end
即通过全局变量希望起到过滤作用。遗憾的是,它完全不工作的。我也不知道错在哪里请大家帮忙看看。哪里写的不对?
谢谢!!!
variable:a1=0,a2=0;
if bb and a1=0 then begin
tsellshort(1,1,lmt,远期卖一+3,0,'802089','zjif09'),orderqueue;
tsell(1,1,lmt,近期买一-3,0,'802089','zjif05'),orderqueue;
tbuy(1,1,lmt,远期卖一+3,0,'802089','zjif09'),orderqueue;
tbuyshort(1,1,lmt,近期买一-3,0,'802089','zjif05'),orderqueue;
a1:=1;
end
if ss and a2=0 then begin
tsell(1,1,lmt,远期买一-3,0,'802089','zjif09'),orderqueue;
tsellshort(1,1,lmt,近期卖一+3,0,'802089','zjif05'),orderqueue;
tbuyshort(1,1,lmt,远期买一-3,0,'802089','zjif09'),orderqueue;
tbuy(1,1,lmt,近期卖一+3,0,'802089','zjif05'),orderqueue;
a2:=1;
end
if bb and a1=0 then begin
。
。
。
a1:=1;
之后a1就是1了,再碰到bb还会执行吗???
刚才看了,出交易动作了,但是黑侠的代码也没有执行。我晕
估计是我自己写反了
周一再看看,谢谢你的回复
bb:=count(c>o,2)=2;
ss:=count(c<o,2)=2;
if bb then begin
tsellshort(tholding>0,1,lmt,c,0,'800309','zjif09'),orderqueue;
tsell(tholding>0,1,lmt,c,0,'800309','zjif05'),orderqueue;
tbuy(tholding=0,1,lmt,c,0,'800309','zjif09'),orderqueue;
tbuyshort(tholding=0,1,lmt,c,0,'800309','zjif05'),orderqueue;
end
if ss then begin
tsell(tholding>0,1,lmt,c,0,'800309','zjif09'),orderqueue;
tsellshort(tholding>0,1,lmt,c,0,'800309','zjif05'),orderqueue;
tbuyshort(tholding=0,1,lmt,c,0,'800309','zjif09'),orderqueue;
tbuy(tholding=0,1,lmt,c,0,'800309','zjif05'),orderqueue;
end