variable:n1=0,n2=0;
VARIABLE:HIGHPRICE=0,LOWPRICE=0;
B:=REF(MA(C,20),1),PRECISION1,LINETHICK0;
KD1:=CROSS(MA(CLOSE,5),MA(CLOSE,30));
Kk1:=CROSS(MA(CLOSE,30),MA(CLOSE,5));
KD2:=CROSS(MA(CLOSE,10),MA(CLOSE,30));
Kk2:=CROSS(MA(CLOSE,30),MA(CLOSE,10));
KD:=(KD1 and n1=0 )OR( KD2 and n1=0 );
KK:=(KK1 and n2=0) OR( KK2 and n2=0);
t1:=currenttime>=t0totime(timetot0(closetime(0))-5*60)and currenttime<t0totime(timetot0(closetime(0))-30);//开仓时间
t2:=currenttime>=t0totime(timetot0(closetime(0))-5*60);//平仓时间
IF HOLDING<0 THEN BEGIN
IF (t2 AND CLOSE>B and n2=0 and STKINDIEX('rb01','公式1.收盘空平,0,6,0,200) and islastbar )or (not(islastbar) and CLOSE>B and n2=0) THEN BEGIN
收盘空平:SELLSHORT(1,1,marketr);
n2:=1;
IF islastbar THEN BEGIN
DEBUGFILE('D:\TEST.TXT',' 收盘空平:%.0f',收盘空平);//输出收盘空平
DEBUGFILE('D:\TEST.TXT','holding:%.0f',holding);//输出HOLDING
DEBUGFILE('D:\TEST.TXT','N2:%.0f',N2);//输出N2
END
END
IF HOLDING=0 THEN BEGIN
IF ( t1 AND KK and islastbar and ENTERBARS!=0 )or (not(islastbar) and kk and ENTERBARS!=0 )THEN BEGIN
IF HOLDING>0 THEN BEGIN
IF (t2 AND CLOSE>B and n2=0 and islastbar )or (not(islastbar) and CLOSE>B and n2=0) THEN BEGIN
收盘多平:SELL(1,1,marketr);
n2:=1;
END
IF HOLDING=0 THEN BEGIN
IF ( t1 AND KK and STKINDIEX('rb01','公式1.空开,0,6,0,200) and islastbar and ENTERBARS!=0 )or (not(islastbar) and kk and ENTERBARS!=0 )THEN BEGIN
空开:BUYSHORT(1=1,1,marketr);
LOWPRICE:=ENTERPRICE;
IF islastbar THEN BEGIN
DEBUGFILE('D:\TEST.TXT',' T1f'&numtostr(T1,0)&' ENTERBARS!=0:'&numtostr(ENTERBARS!=0,1)&' KK:'&numtostr(KK,0)&' N2:'&numtostr(N2,0),0); //输出开仓条件
DEBUGFILE('D:\TEST.TXT',' 空开:%.0f',空开);//输出空开
DEBUGFILE('D:\TEST.TXT','holding:%.0f',holding);//输出HOLDING
//DEBUGFILE('D:\TEST.TXT','N2:%.0f',N2);//输出N2
END
END
END