variable: zhisunflag=0,zhisun=close;
duoru:hhv(high,in),coloryellow;
duochu:llv(low,out),coloryellow;
kongru:llv(low,in),coloryellow;
kongchu:hhv(high,out),coloryellow;
zhisunflag:=holding*ref(holding,1);
KD:=cross(close,ref(duoru,1)) and holding=0; //开多条件
PD:=cross(ref(duochu,1),close) and holding>0; //平多条件
KK:=cross(ref(duochu,1),close) and holding=0; //开空条件
PK:=cross(close,ref(duoru,1)) and holding<0; //平空条件
平空:SELLSHORT(PK,1,THISCLOSE); //平空信号
开多:BUY(KD AND HOLDING=0,1,THISCLOSE); //开多信号
平多:SELL(PD,1,THISCLOSE); //平多信号
开空:BUYSHORT(KK AND HOLDING=0,1,THISCLOSE); //开空信号
if holding>0 and ref(holding,1)<=0 then zhisun:=low -50;
if holding<0 and ref(holding,1)>=0 then zhisun:=high+50;
止损:zhisun,colorblue,linethick3; //止损线
持仓:holding,linethick0;
资产:asset,noaxis;
可用现金:cash(0),linethick0;