这个程序自己读取图表程序中的holding,这样就不要修改程序了。可以达到以下目的:1.不平今;
2.控制日内开仓次数不超过10次;
3.在一定程度上突破了日开仓10手限制(靠解锁,需要的资金要大一些);
//不平日内开仓,且控制日内开仓不超过10手。
r1:=todaybar-1;
tn:=1;//每次交易手数,要和主程序的一致
r4:=stkindiex('if00','qq24xz.持仓(2)',0,21,5,0),linethick0;//
r6:r4,linethick0;
rr:r6-ref(r6,1),noaxis;
//re:sum(abs(rr),r1+1),noaxis;
k1:=tbuyholding(0)=0;
k2:=tsellholding(0)=0;
r10:=tbuyholding(1);
r11:=abs(tsellholding(1));
//********************
GLOBALVARIABLE:a1=0;
if r1=0 then a1:=0;
//********************
if rr>0 and k2 then
begin
if r11>=rr then
begin
tsellshort(1,rr,lmt,c);
end
if r11<rr and r11>0 then
begin
tsellshort(1,r11,lmt,c);
tbuy(1,rr-r11,lmt,c);
a1:=a1+rr-r11;
end
if r11=0 then
begin
tbuy(1,rr,lmt,c);
a1:=a1+rr;
end
end
if rr<0 and k1 then
begin
if r10>=abs(rr) then
begin
tsell(1,abs(rr),lmt,c);
end
if r10<abs(rr) and r10>0 then
begin
tsell(1,r10,lmt,c);
tbuyshort(1,abs(rr)-r10,lmt,c);
a1:=a1+abs(rr)-r10;
end
if r10=0 then
begin
tbuyshort(1,abs(rr),lmt,c);
a1:=a1+abs(rr);
end
end
//************************
if rr>0 and not(k2) and a1<10-rr then
begin
tbuy(1,rr,lmt,c);
a1:=a1+rr;
end
if rr>0 and not(k2) and a1>=10-rr and a1<10 then
begin
r13:=max(10-a1,1);
tbuy(1,r13,lmt,c);
a1:=10;
end
//---------------------------
if rr<0 and not(k1) and a1<10-abs(rr) then
begin
tbuyshort(1,abs(rr),lmt,c);
a1:=a1+abs(rr);
end
if rr<0 and not(k1) and a1>=10-abs(rr) and a1<10 then
begin
r14:=max(10-a1,1);
tbuyshort(1,r14,lmt,c);
a1:=10;
end
//------每天将10限制交易完(这个可以不做)----------------
r20:=intpart((10-a1)/2);
if currenttime>145955 and r20>0 then
begin
tbuy(1,r20,mkt);
tbuyshort(1,r20,mkt);
a1:=10;
end
[此贴子已经被作者于2016/4/3 17:52:21编辑过]
如果对锁但太多可以在集合竞价是平掉一些。没有滑点,只有交易手续费
我用的EXTGBDATA和EXTGBDATASET,在出现意外的时候,还能手动干预一下