N:=20;//停止开仓根数
M:=3;//亏损10数据
MM:=10;//盈利百分比
S1:=5;//开仓手数
S2:=2;//加仓手数MA5:MA(C,5);
MA10:MA(C,10);
MA20:MA(C,20);
MA30:MA(C,30);
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
J:=3*K-2*D;
DD:=MA5>MA10&&MA10>MA20&&MA20>MA30;
KK:=MA5<MA10&&MA10<MA20&&MA20<MA30;
RISK:=MONEYTOT>INITMONEY*(1+MM/100);
多:CROSS(MA5>MA10&&K>D&&C>MA20,0.5)&&COUNT(CROSS(MA5>MA10&&K>D&&C>MA20,0.5),BARSLAST(CROSS(MA5<MA10&&K<D&&C<MA20,0.5))+1),WORD(0,’↑’),COLORBLUE,FONTSIZE40,VALIGN0;
空:CROSS(MA5<MA10&&K<D&&C<MA20,0.5)&&COUNT(CROSS(MA5<MA10&&K<D&&C<MA20,0.5),BARSLAST(CROSS(MA5>MA10&&K>D&&C>MA20,0.5))+1),WORD(1,’↓’),COLORGREEN,FONTSIZE40;
多,SOUND(‘A’);
空,SOUND(‘B’);
LS:=(BARSSP=1||BARSBP)&&TNUMSEQLOSS=M;
//做多策略
多&&COUNTSIG(SP,DAYBARPOS)+COUNTSIG(BP,DAYBARPOS)<3&&COUNT((BARSSP=1||BARSBP=1)&&RISK,BARPOS)=0&&IF(ISLASTSP||ISLASTBP,BARSLAST(LS)>N,1),BK;
DD,ADD_LONG(S2);
C<=REF(LV(L,6)-23*MINPRICE,BARSBK),SP;
空&&COUNTSIG(SP,DAYBARPOS)+COUNTSIG(BP,DAYBARPOS)<3,SP;
//做空策略
空&&COUNTSIG(SP,DAYBARPOS)+COUNTSIG(BP,DAYBARPOS)<3&&COUNT((BARSSP=1||BARSBP=1)&&RISK,BARPOS)=0&&IF(ISLASTSP||ISLASTBP,BARSLAST(LS)>N,1),SK;
KK,ADD_SHORT(S2);
C>=REF(HV(H,6)+23*MINPRICE,BARSSK),BP;
多&&COUNTSIG(SP,DAYBARPOS)+COUNTSIG(BP,DAYBARPOS)<3,BP;
//设置
AUTOFILTER;
T_COMMAND(S1);