if holding>0 and kkcond then sell(1,1,market);
if holding<0 and kdcond then sellshort(1,1,market);
if holding=0 and buycond then buy(1,1,market);
if holding=0 and sellcond then buyshort(1,1,market);
改为如下,出现限价单子?,未成交单
//后台持仓同步系统
cc:=holding;
if holding>0 and ref(kkcond,1) then sell(1,ss,marketr);
if holding<0 and ref(kdcond,1) then sellshort(1,ss,marketr);
if holding=0 and ref(buycond,1) then buy(1,ss,marketr);
if holding=0 and ref(sellcond,1) then buyshort(1,ss,marketr);
tm:=30;//撤单时间
wt:=tremainqty(0,'',stklabel);
buyhold:=tbuyholdingex('',stklabel,1);
sellhold:=tsellholdingex('',stklabel,1);
if wt>0.5 and tsubmit(0)>tm then tcancelex(1,0,'',stklabel);
if wt<0.5 then begin
kc1:=max(cc,0)-buyhold;
kc2:=abs(min(cc,0))-sellhold;
if kc1<-0.5 then tsell(1,SS,mkt,0,0,'');
if kc2<-0.5 then tsellshort(1,SS,mkt,0,0,'');
if sellhold<0.5 and kc1>0.5 then tbuy(1,SS,mkt,0,0,'');
if buyhold<0.5 and kc2>0.5 then tbuyshort(1,SS,mkt,0,0,'');
end
还有//交易系统 走完K线模式
if holding>0 and ref(kkcond,1) and not(islastbar) then sell(1,ss,marketr);
if holding<0 and ref(kdcond,1) and not(islastbar) then sellshort(1,ss,marketr);
if holding=0 and ref(buycond,1) and not(islastbar) then buy(1,ss,marketr);
if holding=0 and ref(sellcond,1) and not(islastbar) then buyshort(1,ss,marketr);
与这也出现未成交单子
//交易系统 走完K线模式
if holding>0 and kkcond and not(islastbar) then sell(1,ss,marketr);
if holding<0 and kdcond and not(islastbar) then sellshort(1,ss,marketr);
if holding=0 and buycond and not(islastbar) then buy(1,ss,marketr);
if holding=0 and sellcond and not(islastbar) then buyshort(1,ss,marketr);
这2者区别是什么?
2楼的第一种写法相当于走完2个k,例如abc3根k线,在b这个k线判断a上是否满足条件,满足条件b走完,c生成时报单
第2种写法相当于走完1根k,判断b上是否满足条件,满足条件c生成时报单
[此贴子已经被作者于2017/7/3 10:22:34编辑过]