止损不知道那里写错,经常在编写模块出现开仓本k线就止损?怎么避免这种现象?
此主题相关图片如下:qq截图20161201161309.png

//建立多头的进场条件
if holding<0 and long then begin
sellshort(1,p,marketr);
buy(1,p,marketr);
end
//建立空头的进场条件
if holding>0 and short then begin
sell(1,p,marketr);
buyshort(1,p,marketr);
end
if holding>0 and l<=max(enterprice-zsx,dstop1) and enterbars1>0 then sell(1,p,market),ignorecheckprice;
if holding<0 and h>=min(enterprice+zsx,kstop1) and enterbars1>0 then sellshort(1,p,market),ignorecheckprice;
if holding=0 and long and ref(c,1)>ref(4,1) then buy(1,p,marketr);
if holding=0 and short and ref(c,1)<ref(4,1) then buyshort(1,p,marketr);
if not(islastbar) or workmode<>1 then exit;
tm:=30;//撤单时间
ac:='614251';//下单账户
wt:=tremainqty(0,ac,stklabel);
buyhold:=tbuyholdingex(ac,stklabel,1);
sellhold:=tsellholdingex(ac,stklabel,1);
if wt>0.5 and tsubmit(0)>tm then tcancelex(1,0,ac,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,abs(kc1),mkt,0,0,ac),allowrepeat;
if kc2<-0.5 then tsellshort(1,abs(kc2),mkt,0,0,ac),allowrepeat;
if sellhold<0.5 and kc1>0.5 then tbuy(1,kc1,mkt,0,0,ac),allowrepeat;
if buyhold<0.5 and kc2>0.5 then tbuyshort(1,kc2,mkt,0,0,ac),allowrepeat;
end
把holding改成CC代替就解决,不知道是什么原因?
enterbars1>0改成enterbars>0
不然这个条件在开仓后恒成立,那么就会同根k线开仓