{}
INPUT:周期(9,1,99,1);
INPUT:交易次数(99,1,99,1);
多空资产:=TRMA( (#DK.多空资产()#),周期),NOAXIS,COLORRED,LINETHICK1;
可用现金:=TRMA( (#DK.可用现金()#),周期),NOAXIS,COLORGREEN,LINETHICK1;
差额:(多空资产-可用现金),NOAXIS,LINETHICK1;
开期:=ENTERBARS,NOAXIS,LINETHICK0;
平期:=EXITBARS,NOAXIS,LINETHICK0;
KD:=(差额>REF(差额,1)) AND HOLDING=0 AND IF(EXITBARS=-1,周期,EXITBARS>=周期+TOTALDAYTRADE); //开多条件
PD:=(差额<REF(差额,1)) AND IF(ENTERBARS=-1,周期,ENTERBARS>=周期+TOTALDAYTRADE); //平多条件
KK:=(差额<REF(差额,1)) AND HOLDING=0 AND IF(EXITBARS=-1,周期,EXITBARS>=周期+TOTALDAYTRADE); //开空条件
PK:=(差额>REF(差额,1)) AND IF(ENTERBARS=-1,周期,ENTERBARS>=周期+TOTALDAYTRADE); //平空条件
IF TOTALDAYTRADE>=交易次数 THEN
SETTRADESIGN(0);
ELSE
SETTRADESIGN(1);
IF OPENPROFIT<=HHV((NETPROFIT),TODAYBAR) THEN BEGIN
SELLSHORT(PK,0,NEXTOPEN); //平空信号
BUY(KD AND HOLDING=0,1,NEXTOPEN); //开多信号
SELL(PD,0,NEXTOPEN); //平多信号
BUYSHORT(KK AND HOLDING=0,1,NEXTOPEN); //开空信号
END
IF OPENPROFIT>=HHV((NETPROFIT),TODAYBAR) AND ABS(HOLDING)<ENTERBARS THEN BEGIN
SELLSHORT(PK,0,NEXTOPEN); //平空信号
BUY(HOLDING=1,ABS(HOLDING)*1,NEXTOPEN); //开多信号
SELL(PD,0,NEXTOPEN); //平多信号
BUYSHORT(HOLDING=-1,ABS(HOLDING)*1,NEXTOPEN); //开空信号
END
{}
INPUT:盈率0停正开(9,0,99,1);
INPUT:亏率0停负开(-2,-99,0,1);
策保:ROUNDS( ("$HIGH##DAY" * MULTIPLIER * ( TACCOUNT(41)+TACCOUNT(42) )/2 ),0),NOAXIS,LINETHICK0;
策率:ROUNDS( 100*ROUNDS(OPENPROFIT/(策保*ABS(HOLDING) ),4),1),NOAXIS,LINETHICK0,COLORGRAY;
帐率:ROUNDS( 100*ROUNDS( (TACCOUNT(4))/(TACCOUNT(28) ),4),1),NOAXIS,LINETHICK0,COLORGRAY;
登陆:TACCOUNT(53),,LINETHICK0;
IF 登陆=1 THEN
盈亏率:=帐率,NOAXIS,LINETHICK0,COLORGRAY;{帐户登陆}
ELSE
盈亏率:=策率,NOAXIS,LINETHICK0,COLORGRAY;{帐户退出}
IF 盈亏率>盈率0停正开 AND 盈率0停正开<>0 THEN BEGIN
SETTRADESIGN(1);
多止盈:SELL(1,1,NEXTOPEN);
空止盈:SELLSHORT(1,1,NEXTOPEN);
END
IF 盈亏率<亏率0停负开 AND 亏率0停负开<>0 THEN BEGIN
SETTRADESIGN(1);
多止损:SELL(1,0,NEXTOPEN);
空止损:SELLSHORT(1,0,NEXTOPEN);
END
{}
仓:HOLDING,LINETHICK0;
//资1:HHV(ASSET,TODAYBAR),NOAXIS,LINETHICK1;
//资2:LLV(ASSET,TODAYBAR),NOAXIS,LINETHICK1;
净:NETPROFIT,NOAXIS,COLORYELLOW,LINETHICK2;
浮:OPENPROFIT,NOAXIS,LINETHICK0;
胜:PERCENTWIN,NOAXIS,LINETHICK0;
盈:PAYOFFRATE,NOAXIS,LINETHICK0;
{}