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